djangoforprofessionals icon indicating copy to clipboard operation
djangoforprofessionals copied to clipboard

Unable to create users from django admin.

Open mlabeeb03 opened this issue 10 months ago • 1 comments

Unknown field(s) (usable_password) specified for CustomUser. Check fields/fieldsets/exclude attributes of class CustomUserAdmin. The CustomUserCreationForm gets inherited from UserCreationForm which does not have a usable_password field that causes this error. We need to either inherit it from AdminUserCreationForm or override the add_fieldsets attribute in the admin.py file to: add_fieldsets = ( ( None, { "classes": ("wide",), "fields": ("username", "email", "password1", "password2"), }, ), )

mlabeeb03 avatar Feb 10 '25 16:02 mlabeeb03

Yes, this is something that changed in Django 5+. I'm fixing it in the update. You can see an up-to-date guide here. Update forms.py to use AdminUserCreationForm.

wsvincent avatar Feb 23 '25 20:02 wsvincent