Fixing Django FieldError at /admin/accounts/customuser/add/

If you are a Django developer who wants to add a custom user model to your project, you’ve likely come across this error on Django versions 5.0 and above.

FieldError at /admin/accounts/customuser/add/
Unknown field(s) (usable_password) specified for C…


This content originally appeared on DEV Community and was authored by Will Vincent

If you are a Django developer who wants to add a custom user model to your project, you've likely come across this error on Django versions 5.0 and above.

FieldError at /admin/accounts/customuser/add/
Unknown field(s) (usable_password) specified for CustomUser. Check fields/fieldsets/exclude attributes of class CustomUserAdmin.

FieldError Message

The issue is around UserCreationForm. In Django versions up to 4.2, you could set your accounts/forms.py file to add updated user creation and change forms.

# accounts/forms.py
from django.contrib.auth.forms import UserCreationForm, UserChangeForm

from .models import CustomUser

class CustomUserCreationForm(UserCreationForm):

    class Meta:
        model = CustomUser
        fields = ("username", "email")

class CustomUserChangeForm(UserChangeForm):

    class Meta:
        model = CustomUser
        fields = ("username", "email")

However, as of Django 5.0, that leads to the above-mentioned FieldError. The fix is straightforward to do, thankfully, which is to swap out UserCreationForm for the newer AdminUserCreationForm instead, which includes the additional usable_password field causing the initial issue.

# accounts/forms.py
from django.contrib.auth.forms import AdminUserCreationForm, UserChangeForm  # new

from .models import CustomUser


class CustomUserCreationForm(AdminUserCreationForm):  # new

    class Meta:
        model = CustomUser
        fields = ("username", "email")


class CustomUserChangeForm(UserChangeForm):

    class Meta:
        model = CustomUser
        fields = ("username", "email")

You can see the related ticket #35678 and forum discussion.

For a complete guide on using a custom user model in Django, refer to this tutorial.


This content originally appeared on DEV Community and was authored by Will Vincent


Print Share Comment Cite Upload Translate Updates
APA

Will Vincent | Sciencx (2025-02-23T00:48:00+00:00) Fixing Django FieldError at /admin/accounts/customuser/add/. Retrieved from https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/

MLA
" » Fixing Django FieldError at /admin/accounts/customuser/add/." Will Vincent | Sciencx - Sunday February 23, 2025, https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/
HARVARD
Will Vincent | Sciencx Sunday February 23, 2025 » Fixing Django FieldError at /admin/accounts/customuser/add/., viewed ,<https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/>
VANCOUVER
Will Vincent | Sciencx - » Fixing Django FieldError at /admin/accounts/customuser/add/. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/
CHICAGO
" » Fixing Django FieldError at /admin/accounts/customuser/add/." Will Vincent | Sciencx - Accessed . https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/
IEEE
" » Fixing Django FieldError at /admin/accounts/customuser/add/." Will Vincent | Sciencx [Online]. Available: https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/. [Accessed: ]
rf:citation
» Fixing Django FieldError at /admin/accounts/customuser/add/ | Will Vincent | Sciencx | https://www.scien.cx/2025/02/23/fixing-django-fielderror-at-admin-accounts-customuser-add/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.