小编Leo*_* Li的帖子

LogoutView 中的模板名称不适用于 django2.1 python3.7

下面是 django.contrib.auth.views.LogoutViews 中的默认设置,

template_name = 'registration/logged_out.html'
Run Code Online (Sandbox Code Playgroud)

我像这样配置我的应用程序的 urls.py:

from django.urls import path
from . import views

from django.conf import settings

from django.contrib.auth.views import LoginView, LogoutView

app_name = 'account'
urlpatterns = [
    #path("login/", views.user_login, name="user_login"),
    path("login/", LoginView.as_view(), name="user_login"),
    path("nlogin/", LoginView.as_view(), {"template_name":"account/login.html"}),
    path("logout/", LogoutView.as_view(), name="user_logout"),
    path("logoutt/", LogoutView.as_view(), {"template_name":"account/logout.html"}),
]
Run Code Online (Sandbox Code Playgroud)

"template_name":"account/login.html" 工作正常,但 "template_name":"account/logout.html" 似乎没有区别,我的代码有什么问题?

django-templates python-3.7 django-2.1

4
推荐指数
1
解决办法
6172
查看次数

标签 统计

django-2.1 ×1

django-templates ×1

python-3.7 ×1