Model not updating to the database

Below is my Extended User Model by using the One to One Field Connection, I have assigned a default value for all the values so that values are assigned automatically when users create their account.

Problem: The User Access Model below is not updated to the database when new user is created. The default values can be seen in the Django Admin Panel, but can’t be accessed from the Database, as it seems it does not update the User Access table.

def generate_unique_user_id():

    while True:
        unique_user_id = random.randint(10000,200000000)
        if UserAccess.objects.filter(unique_user_id=unique_user_id).count() == 0:
            break

    return unique_user_id

def profile_pic_path(instance, filename):
    ext = filename.split('.')[-1]
    uuid = shortuuid.uuid()
    filename = f"{uuid}.{ext}"
    return os.path.join('UserProfilePhoto/', filename)


# Create your models here.
class UserAccess(models.Model):
    ACCESS_STATUS_CHOICES = [
        ('CUSTOMER', 'Customer'),
        ('STAFF', 'Staff'),
        ('SUPER-USER', 'Super-User'),
        ('ADMIN', 'Admin'),
]

    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='useraccess')
    unique_user_id = models.IntegerField(default=generate_unique_user_id, unique=True, primary_key=True)
    access_level = models.IntegerField(default=1, validators=[MinValueValidator(1), MaxValueValidator(15)])
    access_status = models.CharField(max_length=11, choices=ACCESS_STATUS_CHOICES, default='CUSTOMER')
    profile_pic = models.ImageField(null=True, blank=True, unique=True, upload_to=profile_pic_path)

    def __str__(self):
        return self.unique_user_id

My Admin Page Displays the default value but the database does not consists of the information, it seems that the data here is not saved to the database.

How are you creating this user model? How are you populating the data in the UserAccess model?
(Can you post the views responsible for this?)

I’ve got it fixed, it seems somehow the Models is only saved when changes is detected, so when I’m specifying all known default values, the Model won’t proceed to save.

I’ve changed the CharField to have a default of None

    access_status = models.CharField(max_length=11, choices=ACCESS_STATUS_CHOICES, default=None)

I was not using any Views on creating a user, as I’m using Djoser to handle User Authentication Endpoints, but I got the problems solved, Thanks.