djangoforprofessionals
djangoforprofessionals copied to clipboard
Unable to create users from django admin.
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"), }, ), )
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.