在django-registration中配置urls

时间:2013-10-08 13:52:24

标签: python django django-urls django-registration

我想我错过了一件小事,但我不知道在哪里。

使用django-registrationn,我有一个像这样的urls配置:

的mysite / urls.py:

url(r'^accounts/', include('registration.backends.vince.urls')),

登记/后端/文斯/ urls.py:

urlpatterns = patterns('',
                   url(r'^activate/complete/$',
                       TemplateView.as_view(template_name='registration/activation_complete.html'),
                       name='registration_activation_complete'),
                   # Activation keys get matched by \w+ instead of the more specific
                   # [a-fA-F0-9]{40} because a bad activation key should still get to the view;
                   # that way it can return a sensible "invalid key" message instead of a
                   # confusing 404.
                   url(r'^activate/(?P<activation_key>\w+)/$',
                       ActivationView.as_view(),
                       name='registration_activate'),
                   url(r'^register/$',
                       RegistrationView.as_view(),
                       name='registration_register'),
                   url(r'^register/complete/$',
                       TemplateView.as_view(template_name='registration/registration_complete.html'),
                       name='registration_complete'),
                   url(r'^register/closed/$',
                       TemplateView.as_view(template_name='registration/registration_closed.html'),
                       name='registration_disallowed'),
                   (r'', include('registration.auth_urls')),
                   )

并在registration / auth_urls.py中:

urlpatterns = patterns('',
                   url(r'^login/$',
                       auth_views.login,
                       {'template_name': 'registration/login.html'},
                       name='auth_login'),
                   url(r'^logout/$',
                       auth_views.logout,
                       {'template_name': 'registration/logout.html'},
                       name='auth_logout'),
                   url(r'^password/change/$',
                       auth_views.password_change,
                       name='auth_password_change'),
                   url(r'^password/change/done/$',
                       auth_views.password_change_done,
                       name='auth_password_change_done'),
                   url(r'^password/reset/$',
                       auth_views.password_reset,
                       {'template_name': 'registration/password_reset_form.html'},
                       name='auth_password_reset'),

当我打开我的url / accounts / login时,我得到了我的模板registration / login.html。

但是当我请求/ accounts / password / reset时,我得到了django的管理员模板,而我正在等待注册/ password_reset_form.html

你能帮忙吗?

2 个答案:

答案 0 :(得分:0)

这是默认

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

激活 filesystem.Loader您需要在TEMPLATE_DIRS

中指定dirs

答案 1 :(得分:0)

我和你有同样的问题。似乎有issues of incompatibility between Django 1.6/7 and django-registration

编辑:来自Calvin Cheng的single bit为我工作:

...确保您的django.contrib.admin应用行位于注册应用行下方;否则,它会优先使用django.contrib.admin的注册模板......