So, here are my files:
settings.py
LOGOUT_REDIRECT_URL = 'refresh'
views.py
def about(request):
return render(request, 'about.html', {})
def refresh(request):
return HttpResponseRedirect(request.META.get("HTTP_REFERER"))
The problem: If I set LOGOUT_REDIRECT_URL = 'about'
, it works fine. Also if I add the code from refresh view to about view, it works fine too. However, when I set LOGOUT_REDIRECT_URL = 'refresh'
I'll get the error 'View name was wrong'. I don't understand why I get this error.
P.S. If there is another way to refresh the page after log out, feel free and tell me it.
CodePudding user response:
You have to pass the name which you have given in your urls.py
file. You have passed refresh
in LOGOUT_REDIRECT_URL = 'refresh'
which don't match the name with urls.py
So either you change the name in urls.py
file or change in setting.py
file.
CodePudding user response:
settings.py
LOGOUT_REDIRECT_URL = 'refresh'
You need to add in settings/urls.py file :-
settings/urls.py
from django.contrib.auth import views as auth_views
path('logout/', auth_views.LogoutView.as_view(template_name='your_template_name.html'), name='logout'),