Opened 9 years ago

Closed 9 years ago

#24631 closed Bug (invalid)

UUIDField makemigration error

Reported by: Muhamad A. Owned by: nobody
Component: Migrations Version: 1.8
Severity: Normal Keywords: migration
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


As I'm using UUIDField to generate a primary key, when I make migration it returns the following

ValueError: Cannot serialize: UUID('613d3463-b9d6-4bf1-9b62-1e31598b2700')
There are some values Django cannot serialize into migration files.
For more, see

Using the following in

from uuid import uuid4
uuid = models.UUIDField(primary_key=True, default=uuid4(), editable=False)

I managed to make this work by using default=uuid4().hex but the value in the migration file is that generated value

Change History (1)

comment:1 by Claude Paroz, 9 years ago

Resolution: invalid
Status: newclosed

Re-read the documentation:
Note that a callable (with the parentheses omitted) is passed to default, not an instance of UUID.

Note: See TracTickets for help on using tickets.
Back to Top