2

I have django project in which I modified Django admin form for editing users , here i have made Password a ReadOnly Field . Thus no one can change user password . But I wants that Staff user can change password . So for that I want to provide a link to Staff users and from that link Staff user can change password of user .

I was wondering if this is possible from Django form (the same model from where I have made the password field readonly) .

My admin form code :

class CustomUserChangeForm(forms.ModelForm):
    password = ReadOnlyPasswordHashField()

    class Meta:
        model = User
n.imp
  • 787
  • 4
  • 11
  • 29

1 Answers1

2

Add the below code in your form

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>."))

as answered here

Community
  • 1
  • 1
Inforian
  • 1,716
  • 5
  • 21
  • 42