Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #8493 -- Fixed a NoReverseMatch when redirecting to password_ch…

…ange/done/ in the admin. Added the ability to override redirects to other password change views for consistency. Thanks for the report mtrichardson.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8473 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ab26efc95286fa3e7e52f5f9ec232055bcd2cbb7 1 parent d4d7bc1
Brian Rosner authored August 23, 2008
3  django/contrib/admin/sites.py
@@ -194,7 +194,8 @@ def password_change(self, request):
194 194
         Handles the "change password" task -- both form display and validation.
195 195
         """
196 196
         from django.contrib.auth.views import password_change
197  
-        return password_change(request)
  197
+        return password_change(request,
  198
+            post_save_redirect='%spassword_change/done/' % self.root_path)
198 199
 
199 200
     def password_change_done(self, request):
200 201
         """
21  django/contrib/auth/views.py
@@ -73,7 +73,10 @@ def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_N
73 73
 
74 74
 def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html',
75 75
         email_template_name='registration/password_reset_email.html',
76  
-        password_reset_form=PasswordResetForm, token_generator=default_token_generator):
  76
+        password_reset_form=PasswordResetForm, token_generator=default_token_generator,
  77
+        post_reset_redirect=None):
  78
+    if post_reset_redirect is None:
  79
+        post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')
77 80
     if request.method == "POST":
78 81
         form = password_reset_form(request.POST)
79 82
         if form.is_valid():
@@ -87,7 +90,7 @@ def password_reset(request, is_admin_site=False, template_name='registration/pas
87 90
                 if not Site._meta.installed:
88 91
                     opts['domain_override'] = RequestSite(request).domain
89 92
             form.save(**opts)
90  
-            return HttpResponseRedirect(reverse('django.contrib.auth.views.password_reset_done'))
  93
+            return HttpResponseRedirect(post_reset_redirect)
91 94
     else:
92 95
         form = password_reset_form()
93 96
     return render_to_response(template_name, {
@@ -98,12 +101,15 @@ def password_reset_done(request, template_name='registration/password_reset_done
98 101
     return render_to_response(template_name, context_instance=RequestContext(request))
99 102
 
100 103
 def password_reset_confirm(request, uidb36=None, token=None, template_name='registration/password_reset_confirm.html',
101  
-                           token_generator=default_token_generator, set_password_form=SetPasswordForm):
  104
+                           token_generator=default_token_generator, set_password_form=SetPasswordForm,
  105
+                           post_reset_redirect=None):
102 106
     """
103 107
     View that checks the hash in a password reset link and presents a
104 108
     form for entering a new password.
105 109
     """
106 110
     assert uidb36 is not None and token is not None # checked by URLconf
  111
+    if post_reset_redirect is None:
  112
+        post_reset_redirect = reverse('django.contrib.auth.views.password_reset_complete')
107 113
     try:
108 114
         uid_int = base36_to_int(uidb36)
109 115
     except ValueError:
@@ -118,7 +124,7 @@ def password_reset_confirm(request, uidb36=None, token=None, template_name='regi
118 124
             form = set_password_form(user, request.POST)
119 125
             if form.is_valid():
120 126
                 form.save()
121  
-                return HttpResponseRedirect(reverse('django.contrib.auth.views.password_reset_complete'))
  127
+                return HttpResponseRedirect(post_reset_redirect)
122 128
         else:
123 129
             form = set_password_form(None)
124 130
     else:
@@ -131,12 +137,15 @@ def password_reset_complete(request, template_name='registration/password_reset_
131 137
     return render_to_response(template_name, context_instance=RequestContext(request,
132 138
                                                                              {'login_url': settings.LOGIN_URL}))
133 139
 
134  
-def password_change(request, template_name='registration/password_change_form.html'):
  140
+def password_change(request, template_name='registration/password_change_form.html',
  141
+                    post_change_redirect=None):
  142
+    if post_change_redirect is None:
  143
+        post_change_redirect = reverse('django.contrib.auth.views.password_change_done')
135 144
     if request.method == "POST":
136 145
         form = PasswordChangeForm(request.user, request.POST)
137 146
         if form.is_valid():
138 147
             form.save()
139  
-            return HttpResponseRedirect(reverse('django.contrib.auth.views.password_change_done'))
  148
+            return HttpResponseRedirect(post_change_redirect)
140 149
     else:
141 150
         form = PasswordChangeForm(request.user)
142 151
     return render_to_response(template_name, {

0 notes on commit ab26efc

Please sign in to comment.
Something went wrong with that request. Please try again.