Skip to content

Commit

Permalink
Update Invitation Email tutorial for Django 1.6+.
Browse files Browse the repository at this point in the history
Previously, has_usable_password() would return False, if the password
was empty, this changed in 1.6, so now we have to explicitly check if
the password is empty.

Thanks to @Wenze for finding this.
  • Loading branch information
Rocky Meza committed Mar 2, 2015
1 parent c4d1daa commit c29669a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/how-to/invitation-email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Then an admin class that uses our form and sends the email::
)

def save_model(self, request, obj, form, change):
if not change and not obj.has_usable_password():
if not change and (not form.cleaned_data['password1'] or not obj.has_usable_password()):
# Django's PasswordResetForm won't let us reset an unusable
# password. We set it above super() so we don't have to save twice.
obj.set_password(get_random_string())
Expand Down

0 comments on commit c29669a

Please sign in to comment.