10

我在目录下找到了一些,tests但我不确定它们是否正确。

通过身份验证模板,我的意思是login.htm,password_reset.htm等。

一些模板可以在以下位置找到:http ://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/

4

4 回答 4

18

虽然Django 文档明确指出“Django 没有为身份验证视图提供默认模板”,但我发现使用管理模板很简单。只需启用管理应用程序,然后将其添加到 urls.py:

url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),
url('^accounts/', include('django.contrib.auth.urls')),

现在所有的身份验证 url 都可以工作,尽管使用 Django 管理员的外观和感觉。

于 2013-05-19T00:45:34.577 回答
10

您可以在django.contrib.admin.templates.registration使用身份验证模板:

logged_out.html
password_change_done.html
password_change_form.html
password_reset_complete.html
password_reset_confirm.html
password_reset_done.html
password_reset_email.html
password_reset_form.html

这些将具有 Django Admin 的外观和感觉,因此我建议对其进行自定义。

于 2011-07-11T14:40:11.793 回答
6

通过复制上面 DZPM 提到的位于django.contrib.admin.templates.registration中的模板,并将它们放入您自己的注册应用程序的模板目录中,例如 *your_proj_root/registration/templates/registration/*

重要的!如果您为模板保留相同的确切文件名,则必须记住确保您的django.contrib.admin应用程序行位于您的注册应用程序行下方;否则,它将优先使用django.contrib.admin的注册模板。

于 2011-08-08T13:50:43.057 回答
5

不,它会在您的模板文件夹中的“注册”目录中查找这些模板。

从文档:

默认情况下,您有责任在名为 registration/login.html 的模板中提供登录表单。

密码重置可选参数:

template_name:用于显示密码重置表单的模板的全名。registration/password_reset_form.html如果未提供,这将默认为。

文档:登录密码重置

于 2011-07-11T06:26:45.943 回答