Django UUIDField modelfield causes an error in Django admin: poorly formed hexadecimal string UUID

I have a Django 1.8 project, and on one of my models I use the new UUIDField, for example:

class MyModel(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)

I also installed my admin.py:

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    pass

When I load the admin page to try to create an instance, I get an error message:

ValueError at /admin/core/mymodel/add/
badly formed hexadecimal UUID string

I can create an instance without problems from the Django ( ./manage.py shell) shell . However, when I did this, I get the same error as before on the admin site even when viewing a list of object instances.

Any thoughts?

+4
source share
1 answer

, id, , id UUIDField. 1, UUID.

.

+6

Source: https://habr.com/ru/post/1606315/


All Articles