# Create Custom UserModel

**URL:** <https://forum.djangoproject.com/t/create-custom-usermodel/37839>\
**Category:** Mystery Errors\
**Created:** [January 10, 2025, 3:09am UTC](https://forum.djangoproject.com/t/create-custom-usermodel/37839 "2025-01-10T03:09:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlsoheyl](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mlsoheyl/32/26216_2.png) [@mlsoheyl](https://forum.djangoproject.com/u/mlsoheyl)\
**Post date:** [January 10, 2025, 3:09am UTC](https://forum.djangoproject.com/t/create-custom-usermodel/37839/1 "2025-01-10T03:09:41Z")

</div>

Hi. I’m new to Django and I try to create custom user.  
Here is my code.  
Django version: _ **Django==5.1.4** _  
App name: _ **accounts.** _  
_ **config/settings.py:** _

```python
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
]

AUTH_USER_MODEL = 'accounts.CustomUser'

```

_ **accounts/models.py** _

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

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

```

_ **accounts/form.py** _

```python
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from .models import CustomUser

class CustomUserCreationFrom(UserCreationForm):
    class Meta:
        model = CustomUser
        fields = UserCreationForm.Meta.fields + ('age', )

class CustomUserChangeForm(UserChangeForm):
    class Meta(UserChangeForm.Meta):
        model = CustomUser
        fields = UserChangeForm.Meta.fields

```

_ **accounts/admin.py:** _

```python
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

from .models import CustomUser
from .forms import CustomUserChangeForm, CustomUserCreationFrom

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

admin.site.register(CustomUser, CustomUserAdmin)

```

after makemigration accounts app and migrate all apps, I get this error (for creating new user):

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/a/b/abd7e7a813d1046a9edc5d7653ed8bbc975c8d94.png)

---

<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:** [January 10, 2025, 3:17am UTC](https://forum.djangoproject.com/t/create-custom-usermodel/37839/2 "2025-01-10T03:17:56Z")

</div>

Welcome @mlsoheyl !

Side note: Please avoid posting screenshots for textual information. In the case of the error summaries being shown in the browser, it’s better if you posted the complete error message and traceback from the runserver console. (And also enclose that text between lines of ```.)

For the issue you’re asking about, 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)  
and
- [FieldError - Unknown field(s) (usable\_password) specified for CustomUser](https://forum.djangoproject.com/t/fielderror-unknown-field-s-usable-password-specified-for-customuser/36560)
