我要保持一個乾淨的URL描述我謨,所以我使用的命名空間:命名空間的URL在Django登記
項目/ urls.py:
urlpatterns = patterns('',
url(r'^contracts/', include('apps.contracts.urls', namespace='contracts')),
url(r'^accounts/', include('apps.registration_custom.backends.vince.urls', namespace='accounts')),
registration_custom /後端/文斯/網址的.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/$',
CustomRegistrationView.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')),
)
有了這個配置,如果我請求/帳號/密碼/ RESET /我得到一個錯誤:
Reverse for 'django.contrib.auth.views.password_reset_done' with arguments '()' and keyword arguments '{}' not found
但是,如果我沒有命名我的網址,我的/ accounts/password/reset/request會清除所有內容。
我的理解是,django/contrib/auth/views/password_reset視圖在'django.contrib.auth.views.password_reset_done'上使用reverse()。而網址調度員會因爲應該詢問'accounts:auth_password_reset_done'而迷路。
我猜對了嗎?
那麼我的選擇是什麼?
編輯。 重定向到的模板代碼/帳戶/密碼/復位:
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="{% trans 'Log in' %}" />
<input type="hidden" name="next" value="{{ next }}" />
</form>
<p>{% trans "Forgot password" %}? <a href="{% url 'accounts:auth_password_reset' %}">{% trans "Reset it" %}</a>!</p>
<p>{% trans "Not member" %}? <a href="{% url 'accounts:registration_register' %}">{% trans "Register" %}</a>!</p>
{% endblock %}
你可以顯示你的模板代碼重定向到'/ account/password/reset /'嗎? – sachitad
@sachitad是的,我編輯我的文章 – user777466