# Custom User Model (AbstractUser class)

**URL:** https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339
**Category:** Using Django
**Created:** [April 10, 2025, 1:34pm UTC](https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339 "2025-04-10T13:34:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Lanuel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lanuel/32/27674_2.png) [@Lanuel](https://forum.djangoproject.com/u/Lanuel)
#### Post date: [April 10, 2025, 1:34pm UTC](https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339/1 "2025-04-10T13:34:38Z")

</div>

I created a custom user model using the AbstractUser class, without including either the password or usable\_password field. However, I encountered the following error in the admin panel when I try to add a new user;  
_FieldError at /admin/accounts/customuser/add/_  
_Unknown field(s) (usable\_password) specified for CustomUser. Check fields/fieldsets/exclude attributes of class CustomUserAdmin._

After investigation, I discovered that the culprit — usable\_password — had been automatically added to the default ‘UserAdmin’ class.

This leads me to the following questions:

1. Why does my CustomUser model appear to inherit the usable\_password field?
2. Why does the AbstractUser/AbstractBaseUser class include usable\_password, even though it is not a legitimate model field?
3. Why is the UserAdmin class attempting to register the default User model, even though my CustomUserAdmin class explicitly defines the fields as:

```auto
class CustomUserAdmin(UserAdmin):
    add_form = CustomUserCreationForm
    form = CustomUserChangeForm
    model = CustomUser
    list_display = ["username", "email", "is_staff", "age"]
    fieldsets = UserAdmin.fieldsets + ((None, {"fields": ("age",)}),)
    add_fieldsets = UserAdmin.add_fieldsets + ((None, {"fields": ("age",)}),)

admin.site.register(CustomUser, CustomUserAdmin)

```

---

<div class="post-metadata">

### Author: ![philgyford](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/philgyford/32/14295_2.png) [@philgyford](https://forum.djangoproject.com/u/philgyford)
#### Post date: [April 10, 2025, 2:20pm UTC](https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339/2 "2025-04-10T14:20:09Z")

</div>

Show the code for your custom user - please format code correctly with ``` on a line before and after the code.

Also show the value of `AUTH_USER_MODEL` from your `settings.py`

---

<div class="post-metadata">

### Author: ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)
#### Post date: [April 10, 2025, 2:38pm UTC](https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339/3 "2025-04-10T14:38:58Z")

</div>

Welcome @Lanuel !

See the threads at

- [when I add new user from admin panel this error HELP!](https://forum.djangoproject.com/t/when-i-add-new-user-from-admin-panel-this-error-help/35124)
- [The purpose of UserCreationForm](https://forum.djangoproject.com/t/the-purpose-of-usercreationform/33836)  
and
- [FieldError - Unknown field(s) (usable\_password) specified for CustomUser - #4 by wsvincent](https://forum.djangoproject.com/t/fielderror-unknown-field-s-usable-password-specified-for-customuser/36560/4)

---

<div class="post-metadata">

### Author: ![Lanuel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lanuel/32/27674_2.png) [@Lanuel](https://forum.djangoproject.com/u/Lanuel)
#### Post date: [April 10, 2025, 7:31pm UTC](https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339/4 "2025-04-10T19:31:51Z")

</div>

Thanks for the heads-up on how to properly format a code. Here is the code for custom user:

```auto
from django.db import models
from django.contrib.auth.models import AbstractUser

class CustomUser(AbstractUser):
    age = models.PositiveIntegerField(null=True, blank=True)

```

From settings:

```auto
AUTH_USER_MODEL = "accounts.CustomUser"

```

---

<div class="post-metadata">

### Author: ![Lanuel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lanuel/32/27674_2.png) [@Lanuel](https://forum.djangoproject.com/u/Lanuel)
#### Post date: [April 10, 2025, 7:33pm UTC](https://forum.djangoproject.com/t/custom-user-model-abstractuser-class/40339/5 "2025-04-10T19:33:49Z")

</div>

Thank you, I’ll take a look.
