我正在使用 Django 3 和 Python 3.7。
我一直在摸索一些模板,但我似乎无法找到“成功”模板,例如“password_change_done”和“password_reset_done”。两者都给出类似的错误消息。
/users/password_change/ 处的 NoReverseMatch
未找到“password_change_done”的反向。'password_change_done' 不是有效的视图函数或模式名称。
我的项目 urls.py 中有这个:
urlpatterns = [
path( "users/", include( "users.urls" ) )
, path( "admin/", admin.site.urls )
, path( "", include( "main.urls" ) ) # Played with this up top, and here on the bottom.
]
在 users\urls.py 中:
urlpatterns = [
# Include default auth urls.
path( "", include( "django.contrib.auth.urls" ) )
...
]
我什至尝试添加一个 TEMPLATES.DIRS 值来指向用户/模板。
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [ os.path.join( BASE_DIR, "users/templates" ) ], # With and Without this.
"APP_DIRS": True,
...
},
},
]
我觉得path( "", include( "django.contrib.auth.urls" ) )
应该包含正确的参考,但我需要单独列出每一个吗?我该怎么做?