B
B
bbquite2021-11-26 10:51:29
Django
bbquite, 2021-11-26 10:51:29

What causes an error with uuid?

There is a model:

class Account(AbstractUser):

    username = None
    id = models.UUIDField(
        primary_key=True, unique=True, default=uuid.uuid4, editable=False)
    phone = models.CharField(
        "Телефон", unique=True, max_length=18,
        validators=[MinLengthValidator(10), MaxLengthValidator(10)])
    email = models.EmailField(
        "Email", unique=True, blank=True, null=True, default=None)

    USERNAME_FIELD = "phone"

After creating the superuser, I try to go to the admin panel and get:
ValidationError at /admin/login/
['Значение “1” не является верным UUID-ом.']

In this line

/usr/lib/python3.8/uuid.py, line 169, in __init__
                raise ValueError('badly formed hexadecimal UUID string')


I entered the database through dbshel, field ID -> 5624a04b-4a50-4399-8896-b30f340194a6
Where does he get this unit from then?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bbquite, 2021-11-26
@WebDev921

I found an error, for some reason the old ID-shnik was preserved in the session

R
Rodion, 2021-11-26
@rodion4dev

Hi
With so much data, it's hard to solve the problem. Most likely, the matter is either in the absence of migrations, or in insufficient customization of the admin panel for the new model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question