Joshua Partogi wrote:
> # Process the data in form.cleaned_data
> user = User()
> new_member = form.save(commit=False)
>
> new_member.password = user.set_password
> ( new_member.password )
> instance = new_member.save()
>
> But it seems that user.set_password is not invoked and I get None.
>
> What is the proper way of doing it?
You have to call set_password() on the user object you wish to set the
password for, not a random new user object. So:
# Process the data in form.cleaned_data
new_member = form.save(commit=False)
new_member.set_password( new_member.password )
instance = new_member.save()
You could put that gubbins in your form's save() method, then it'd be
taken care of wherever you might save the form (and probably use
self.cleaned_data['password'] - see the UserCreationForm in
django/contrib/auth/forms.py).
ATB,
Matthew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---