django logout redirects me to administration page

ducin picture ducin · Mar 18, 2013 · Viewed 20.3k times · Source

I have provided a simple login functionality. For logout, I tried to use the built-in one. This is my urls.py:

(r'', include('django.contrib.auth.urls')),

And this is my template file:

{% if user.is_authenticated %}
logged in as {{ user }}
(<a href="{% url "logout" %}">logout</a>)
{% else %}

I have also enabled the default django admin site. When I click logout, it shows me the administration logout view. How can I pass the logout next page attribute to tell django which view to render?

Answer

Gautham Nookala picture Gautham Nookala · Dec 11, 2015

If you are seeing the log out page of the Django administration site instead of your own log out page (your_application/templates/registration/logged_out.html), check the INSTALLED_APPS setting of your project and make sure that django.contrib.admin comes after 'your_application'. Both templates are located in the same relative path and the Django template loader will use the first one it finds.