5👍
You are using contrib.auth
‘s logout
view in your urls.py
. This view redirects to the URL specified by 'next_page'
. You provide '/account/logout'
as next_page
— where again the logout
view is called!
That leads to an (infinite) redirect loop: the view redirects to itself.
Try instead: in your own logout
view:
# no redirecting here!
return render(request, 'account/logout.html',
context_instance=RequestContext(request))
Add a url for that view in account/urls.py
:
url(r'^post-logout/$', logout, name='post-logout'),
# logout being your own view
Then provide that url as 'next_page'
to the actual (auth
) logout:
url(r'^logout/$', 'django.contrib.auth.views.logout',
{'next_page': '/account/post-logout'}, name='logout'),
7👍
I was having same issue, but then I kept reading
“If you are seeing the log out page of the Django administration site instead of your own log out page, check the INSTALLED_APPS setting of your project and make sure that django.contrib.admin comes after the account application. Both templates are located in the same relative path and the Django template loader will use the first one it finds.”
- [Django]-Django request GET parameter value list
- [Django]-Django: Using 2 different AdminSite instances with different models registered
- [Django]-Change model to inherit from abstract base class without changing DB
- [Django]-Using HttpResponseRedirect, but browser is not showing correct URL
- [Django]-.Stay on SSL across redirects
0👍
The solution to the problem is to map the url as follows
url(r’^logout/$’, ‘django.contrib.auth.views.logout’, { ‘template_name’: ‘account/logout.html’,}, name=’logout’ ),
- [Django]-How to use C# client to consume Django/Python web service (all methods are returning null)?
- [Django]-Unknown command: 'collectstatic' Django 1.7
- [Django]-Django over https form redirection issues