[Django]-Django admin change user password

2๐Ÿ‘

โœ…

The problem was solved by :

class MyAdminPasswordChangeForm(AdminPasswordChangeForm):

    def save(self, commit=True):
        """
        Saves the new password.
        """
        password = self.cleaned_data["password1"]
        self.user.myuser.set_password(password)
        if commit:
            self.user.myuser.save()
        return self.user.myuser

and

class ProfileAdmin(UserAdmin):
    change_password_form = MyAdminPasswordChangeForm
๐Ÿ‘คhsbr13

1๐Ÿ‘

I ran into this error after upgrading to django 2.x. I had set up my own UserChangeForm, so I just had to update its url:

class EmailUserChangeForm(forms.ModelForm):
    password = ReadOnlyPasswordHashField(label=_("Password"), help_text=_(
        "Raw passwords are not stored, so there is no way to see "
        "this user's password, but you can change the password "
-        "using <a href=\"password/\">this form</a>."))
+        "using <a href=\"../password/\">this form</a>."))
๐Ÿ‘คAaron

Leave a comment