django logout将我重定向到管理页面 [英] django logout redirects me to administration page

查看:480
本文介绍了django logout将我重定向到管理页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供了一个简单的登录功能。对于注销,我试图使用内置的。这是我的urls.py:

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

这是我的模板文件:

  {%if user.is_authenticated%} 
以{{user}}登录
(< a href ={%urllogout%} > logout< / a>)
{%else%}

默认的django管理站点。当我点击注销,它显示管理注销视图。如何传递注销下一页属性来告诉django要呈现的视图?

解决方案

如果您看到注销页面的Django管理站点,而不是您自己的注销页面(your_application / templates / registration / logged_out.html),请检查项目的INSTALLED_APPS设置,并确保django.contrib.admin是在your_application之后。两个模板位于相同的相对路径中,Django模板加载器将使用它找到的第一个。


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?

解决方案

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.

这篇关于django logout将我重定向到管理页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆