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.
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.