[Fixed]-Hashed password becomes the real password

1👍

I think this is occurring because the UserChangeForm default uses a ReadOnlyPasswordHashField for the field password.

I would try:

class UserCreationForm(forms.ModelForm):

     password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ('Email','name','is_staff','is_superuser','Teacher',
              'Student', 'Data_Joined', 'Is_active')

    def save(self, commit=True):
        user = super(UserCreationForm, self).save(commit=False)
        user.set_password(self.cleaned_data["password1"])
        if commit:
            user.save()
    return user

Leave a comment