python - Reverse for 'password_change_done' with arguments '()' and keyword arguments '{}' not found -


background

i trying customize authentication views in django project, can't seem customized password_change view run. use django 1.8.2 , python 2.7.

the urls.py of module userauth looks following:

from django.conf.urls import patterns, include, url  urlpatterns = patterns('django.contrib.auth.views',     url(r'^login/$', 'login', {'template_name': 'userauth/login.html'},         name='userauth_login'),     url(r'^logout/$', 'logout', {'next_page': '/'},         name='userauth_logout'),     url(r'^password-change/$', 'password_change',         {'template_name': 'userauth/password_change_form.html'},         name='userauth_password_change'),     url(r'^password-change-done/$', 'password_change_done',         {'template_name': 'userauth/password_change_done.html'},         name='userauth_password_change_done'), ) 

this referenced in main urls.py this:

urlpatterns = [     url(r'^admin/', include(admin.site.urls)),     url(r'^account/', include('userauth.urls')), ] 

the template of userauth/password_change_form.html

{% extends "base.html" %}  {% block title %}{{ block.super }} - change password{% endblock %}  {% block toggle_login %}{% endblock %}  {% block content %} <form action="{% url 'userauth_password_change' %}" method="post" accept-charset="utf-8">   {{ form.as_p }}   {% csrf_token %}   <input type="submit" value="change password"/> </form> {% endblock %} 

and template userauth/password_change_done.html

{% extends "base.html" %}  {% block title %}{{ block.super }} - password change successful{% endblock %}  {% block content %} <p>your password has been changed successfully.</p> <a href="{% url 'products_product_index' %}">back account</a> {% endblock %} 

the problem

when open 'password_change_done' page (at /account/password-change-done), fine.

but @ 'password-change' (/accunt/password-change) getting error:

noreversematch @ /account/password-change/

reverse 'password_change_done' arguments '()' , keyword arguments '{}' not found. 0 pattern(s) tried: []

what tried

i have no idea, why should happening.

  1. i tried removing single quotes url 'userauth_password_change'
  2. i made sure password-change-donepage exists in urls.py , available
  3. i read solutions @ reverse '*' arguments '()' , keyword arguments '{}' not found, django: reverse 'detail' arguments '('',)' , keyword arguments '{}' not found, django change_password noreversematch @ /accounts/password/change/ (and few more, tried solutions there, can't find problem in own code)

any appreciated. thank you!

ok, suggested solution me didn't work here. i'm using django 1.8.8 in application specific app label, need specify url in template e.g. app_label:url_name. meant reverse password_change_done never work since it's app_label:password_change_done.

but thankfully there's solution: 'post_change_redirect'. hence specified password_change this:

url(r'^password_change$', 'django.contrib.auth.views.password_change', {'template_name': 'password_change.html', 'post_change_redirect': 'app_label:password_change_done'}, name='password_change'), 

i'm sure others use overcome problem above , still keep own custom url name.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -