# Error when extending the default user model

**URL:** <https://forum.djangoproject.com/t/error-when-extending-the-default-user-model/28844>\
**Category:** Mystery Errors\
**Created:** [March 8, 2024, 5:28am UTC](https://forum.djangoproject.com/t/error-when-extending-the-default-user-model/28844 "2024-03-08T05:28:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ermantraun](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ermantraun/32/19395_2.png) [@ermantraun](https://forum.djangoproject.com/u/ermantraun)\
**Post date:** [March 8, 2024, 5:28am UTC](https://forum.djangoproject.com/t/error-when-extending-the-default-user-model/28844/1 "2024-03-08T05:28:32Z")

</div>

Error when extending the default user model and using createsuperuser:

```auto
python manage.py createsuperuser
Username: white
Email address: ****
Password: 
Password (again): 
CommandError: This field cannot be blank.; This field cannot be blank.; This field cannot be blank.; This field cannot be blank.; This field cannot be blank.; This field cannot be blank.; This field cannot be blank.; This field cannot be null.; This field cannot be null.

```

My model:

```auto
class User(AbstractUser):
    country = models.CharField(max_length=120, default='')
    city = models.CharField(max_length=120, default='') 
    street_name = models.CharField(max_length=120, default='')
    postcode = models.CharField(max_length=20, default='')  
    additional_address_details = models.CharField(max_length=500, default='')  
    phone_number = models.CharField(max_length=20, default='')
    wish_list = models.OneToOneField("WishList", on_delete=models.CASCADE)
    basket = models.OneToOneField("Basket", on_delete=models.CASCADE)
    images = GenericRelation("Image")

```

Also some customizations in settings.py:

```auto
AUTH_USER_MODEL = "furbar.User"
INSTALLED_APPS = [
    'furbar.apps.FurbarConfig',
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

```

admin.py:

```auto
from django.contrib import admin
from . import models
from django.contrib.auth.admin import UserAdmin

admin.site.register(models.User, UserAdmin)

```

This method (instead of using OneToOneField to extend the standard model) was chosen after recommendations along the lines of “it’s more correct” (honestly, I don’t know why it’s more correct, but I preferred to listen to the “experienced” (I guess))

---

<div class="post-metadata">

**Author:** ![ermantraun](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ermantraun/32/19395_2.png) [@ermantraun](https://forum.djangoproject.com/u/ermantraun)\
**Post date:** [March 8, 2024, 5:43am UTC](https://forum.djangoproject.com/t/error-when-extending-the-default-user-model/28844/2 "2024-03-08T05:43:32Z")

</div>

By adding parameters blank=True, null=True in the fields definition I solved the problem, but it is not exactly what I would like, because then in the admin the corresponding fields are not displayed for my model

---

<div class="post-metadata">

**Author:** ![antoinehumbert](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/antoinehumbert/32/14851_2.png) [@antoinehumbert](https://forum.djangoproject.com/u/antoinehumbert)\
**Post date:** [March 8, 2024, 7:31am UTC](https://forum.djangoproject.com/t/error-when-extending-the-default-user-model/28844/3 "2024-03-08T07:31:45Z")

</div>

Hi,

You must define the `REQUIRED_FIELDS` attribute of your user model class with the list of fields that do not accept a null/blank value: see [Customizing authentication in Django | Django documentation | Django](https://docs.djangoproject.com/en/5.0/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS)
