Password Change Usage

103 views
Skip to first unread message

Chris

unread,
Oct 8, 2008, 10:29:52 PM10/8/08
to Django users
Does anyone know of an example for using
django.contrib.auth.views.password_change?

All the docs seem to mention is how to specify it's template. After
poking around in the code, I found it exposes new_password1 and
new_password2 and I setup a basic form. However, it never redirects to
the default password_change_done view, even though the passwords
entered are identical.

meppum

unread,
Oct 8, 2008, 11:26:21 PM10/8/08
to Django users
That's odd, I was just about to post about a similar issue I was
having. Mine attempts to redirect but gives an error on the line
calling reverse to the password_change_done view.

Chris Spencer

unread,
Oct 8, 2008, 11:56:43 PM10/8/08
to django...@googlegroups.com
Yeah, this has been a big let down. What I'd hoped would be a few
minutes setting up a basic site framework has turned into several
hours wasted on boilerplate. The lack of docs, templates, and strange
bugs like these leads me to think that django-registration isn't fully
baked. I'm simply writing my own at this point, since I can't find a
single example through Google of someone who's used that portion of
registration successfully.

Chris

meppum

unread,
Oct 9, 2008, 12:04:43 AM10/9/08
to Django users
Okay, looks like this is a bug. I've never created a ticket for Django
but I'll look it up. For now the work around is to change your url
config to look something like this:

url(r'^password/change/$', auth_views.password_change,
{'post_change_redirect': 'registration/
registration_change_done.html'}, name='auth_password_change')

where 'post_change_redirect' is the path to the template for the
registration_change_done view. Hope this helps.

On Oct 8, 11:56 pm, "Chris Spencer" <chriss...@gmail.com> wrote:
> Yeah, this has been a big let down. What I'd hoped would be a few
> minutes setting up a basic site framework has turned into several
> hours wasted on boilerplate. The lack of docs, templates, and strange
> bugs like these leads me to think that django-registration isn't fully
> baked. I'm simply writing my own at this point, since I can't find a
> single example through Google of someone who's used that portion of
> registration successfully.
>
> Chris
>

meppum

unread,
Oct 9, 2008, 12:12:55 AM10/9/08
to Django users
Scratch that.

Try this, it's working fine. The short story is that the reverse
lookup checks your own url config.

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'),

-meppum

Carl Meyer

unread,
Oct 9, 2008, 9:24:38 AM10/9/08
to Django users
On Oct 8, 11:56 pm, "Chris Spencer" <chriss...@gmail.com> wrote:
> Yeah, this has been a big let down. What I'd hoped would be a few
> minutes setting up a basic site framework has turned into several
> hours wasted on boilerplate. The lack of docs, templates, and strange
> bugs like these leads me to think that django-registration isn't fully
> baked. I'm simply writing my own at this point, since I can't find a
> single example through Google of someone who's used that portion of
> registration successfully.

django-registration works great for me out of the box, with all the
features. You'll want the latest SVN version, as there are a number
of bugs fixed since the last release (0.6).

You also shouldn't need to write your own form, as the password_change
view (just like all the others) gives you a template variable "form"
that you can just render normally (with form.as_ul or siblings, or
just iterating over the fields).

Carl

Chris Spencer

unread,
Oct 10, 2008, 7:44:11 AM10/10/08
to django...@googlegroups.com
That might be the problem then. I dislike the default markup, so I'm
using my own. How do you find if the form as errors? Using
http://docs.djangoproject.com/en/dev/topics/forms/ as a guide, I've
tried using form.has_errors, form.errors and form.message.errors, but
Registration doesn't seem to use any of those.

Chris

Carl Meyer

unread,
Oct 10, 2008, 11:37:43 AM10/10/08
to Django users
On Oct 10, 7:44 am, "Chris Spencer" <chriss...@gmail.com> wrote:
> That might be the problem then. I dislike the default markup, so I'm
> using my own. How do you find if the form as errors? Usinghttp://docs.djangoproject.com/en/dev/topics/forms/as a guide, I've
> tried using form.has_errors, form.errors and form.message.errors, but
> Registration doesn't seem to use any of those.

RegistrationForm is a normal Form instance. Most errors will be
attached to specific fields, and thus will be in
form.field_name.errors, as documented. Errors not associated with any
particular field are available from form.non_field_errors(), as
documented here [1].

HTH,
Carl

[1] http://docs.djangoproject.com/en/dev/ref/forms/validation/

Chris Spencer

unread,
Oct 10, 2008, 10:50:21 PM10/10/08
to django...@googlegroups.com
Thanks.
Reply all
Reply to author
Forward
0 new messages