【问题标题】:Django-Registration redux password change forwards to index pageDjango-Registration redux 密码更改转发到索引页面
【发布时间】:2017-10-26 19:32:27
【问题描述】:

我可以使用 Django-Registration redux 登录和注册,它工作正常,除了密码更改转发到:http://127.0.0.1:8000/?next=/accounts/password/change/ 登陆主页。

这些是我的应用网址:

class MyRegistrationView(RegistrationView):
    def get_success_url(self,user):
        return('/createprofile/')

urlpatterns=[
    url(r'^$', views.index, name='index'),
    url(r'^city/(?P<city_name_slug>[\w\-]+)/$', views.show_city, name='show_city'),
    url(r'^user/(?P<username>[\w\-]+)/$', views.show_profile, name='show_profile'),
    url(r'^search/$', views.search, name='search'),
    url(r'accounts/register/$', MyRegistrationView.as_view(), name='registraion_register'),
    url(r'^accounts/', include('registration.backends.simple.urls')),
    url(r'^createprofile/$', views.createprofile, name="createprofile"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

这是我用来更改密码的链接:

<p>
    forgot your password? Ney bother.
    <a href="{% url 'excurj:auth_password_change' %}">Reset password</a>
</p>

这是password_change_form.html表单与其他注册表单存放在同一位置:

{% extends 'base.html' %}
{% load i18n %}
{% load crispy_forms_tags %}

{% block content %}
<form method="post" action=".">
  {% csrf_token %} 
  {{ form|crispy }}

  <input type="submit" value="{% trans 'Submit' %}" />
</form>
{% endblock %}

这是http://127.0.0.1:8000/accounts/的结果:

编辑:当用户未登录时会发生上述情况。登录时会出现此错误:

NoReverseMatch 在 /accounts/password/change/ 反向 'auth_password_change_done' 带有参数 '()' 和关键字参数 '{}' 未找到。尝试了 0 个模式:[]

【问题讨论】:

    标签: python django django-templates change-password


    【解决方案1】:

    问题原来是我放这个的:

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

    但是,在应用程序的 url.py 中,它需要在项目的 url.py 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-31
      • 2013-03-04
      相关资源
      最近更新 更多