Django是否附带用于django.contrib.auth模块的认证模板?
我在tests
目录下找到了一些东西,但不太确定它们是不是正确的。
我说的认证模板是指login.htm
、password_reset.htm
等文件。
一些模板可以在这里找到:http://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/
4 个回答
11
你可以使用在 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的管理后台一致,所以我建议你可以对它们进行一些自定义修改。
19
虽然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')),
现在所有的认证网址都可以用了,只不过它们的样式是Django管理员的风格。