After submitting the password change form, I sometimes get this error, and sometimes the password change is successful.
AssertionError at /portal/user/mypass/
PasswordChangeRequired object can't be deleted because its id attribute is set to None.
Request Method: POST
Request URL: https://172.16.22.143/portal/user/mypass/
Django Version: 1.7.7
Exception Type: AssertionError
Exception Value:
PasswordChangeRequired object can't be deleted because its id attribute is set to None.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/base.py in delete, line 735
Python Executable: /usr/local/bin/uwsgi
Python Version: 2.7.3
/usr/local/lib/python2.7/dist-packages/password_policies/forms/init.py in save
raise forms.ValidationError(self.error_messages['password_similar'])
return cleaned_data
def save(self, commit=True):
user = super(PasswordPoliciesChangeForm, self).save(commit=commit)
try:
if user.password_change_required:
user.password_change_required.delete() ...
except ObjectDoesNotExist:
pass
return user
One solution is to check the user.password_change_required.id is not None before calling .delete().
After submitting the password change form, I sometimes get this error, and sometimes the password change is successful.
AssertionError at /portal/user/mypass/ PasswordChangeRequired object can't be deleted because its id attribute is set to None. Request Method: POST Request URL: https://172.16.22.143/portal/user/mypass/ Django Version: 1.7.7 Exception Type: AssertionError Exception Value:
PasswordChangeRequired object can't be deleted because its id attribute is set to None. Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/base.py in delete, line 735 Python Executable: /usr/local/bin/uwsgi Python Version: 2.7.3
/usr/local/lib/python2.7/dist-packages/password_policies/forms/init.py in save raise forms.ValidationError(self.error_messages['password_similar']) return cleaned_data def save(self, commit=True): user = super(PasswordPoliciesChangeForm, self).save(commit=commit) try: if user.password_change_required: user.password_change_required.delete() ... except ObjectDoesNotExist: pass return user
One solution is to check the user.password_change_required.id is not None before calling .delete().