BasicallyHereIt is the same as, but since there is no answer, I will ask you a question.
I wrote uuid as below in the model of django.

class User (models.Model):
    class Meta:
        db_table ='user'
    def get_uuid_no_dash ():
        return uuid.uuid4 (). hex
    # User ID
    id = models.CharField (primary_key = True, default = get_uuid_no_dash, max_length = 33, editable = False, unique = True)
    #id = models.UUIDField (primary_key = True, default = uuid.uuid4, editable = False)
    # username
    user_name = models.CharField (verbose_name = "username", max_length = 20, unique = True)
    # Profile photo (not required)
    prof_image = models.ImageField (upload_to ='images', verbose_name = "profile image", null = True, blank = True)
    # Self-introduction (not required)
    intro = models.TextField (verbose_name ='introduction', null = True, blank = True)
    #Skill tag
    skills = TaggableManager (verbose_name ='skills', blank = True)
    def __str __ (self):
        return self.user_name

After that, when I migrated and tried to add data with admin, the following error occurred.

ValueError at/admin/user/user/add /
Field'object_id' expected a number but got '78a0767cb607488087a73f17565bbf77'.

Probably the cause is that the letters are mixed even though only numbers are accepted, but I have little knowledge about the database and I am having trouble finding a solution. Please let me know if there is a way to avoid this error.

  • Answer # 1

    It seems impossible with sqlite anyway, so I decided to change to mysql

  • Answer # 2

    I thought I should use uuidField, but do I want to eliminate hyphens instead of uuid ??