1

我想我错过了一些东西,但我不知道在哪里。

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

我的网站/urls.py:

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

注册/后端/vince/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

你能帮我吗?

4

2 回答 2

1

这是默认设置

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

激活filesystem.Loader您需要指定目录TEMPLATE_DIRS

于 2014-01-04T08:23:31.557 回答
0

我和你有同样的问题。Django 1.6/7 和 django-registration 之间似乎存在不兼容的问题。

编辑: Calvin Cheng 的这一点对我有用:

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

于 2015-03-27T14:55:49.083 回答