[Django] #24631: UUIDField makemigration error

27 views
Skip to first unread message

Django

unread,
Apr 11, 2015, 10:40:16 PM4/11/15
to django-...@googlegroups.com
#24631: UUIDField makemigration error
----------------------------+-----------------------
Reporter: muhamada | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords: migration
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-----------------------
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 https://docs.djangoproject.com/en/1.8/topics/migrations
/#migration-serializing
}}}

Using the following in models.py
{{{
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

--
Ticket URL: <https://code.djangoproject.com/ticket/24631>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 12, 2015, 4:20:29 AM4/12/15
to django-...@googlegroups.com
#24631: UUIDField makemigration error
----------------------------+--------------------------------------
Reporter: muhamada | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: invalid

Keywords: migration | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by claudep):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

Re-read the documentation:
https://docs.djangoproject.com/en/1.8/ref/models/fields/#uuidfield
`Note that a callable (with the parentheses omitted) is passed to default,
not an instance of UUID.`

--
Ticket URL: <https://code.djangoproject.com/ticket/24631#comment:1>

Reply all
Reply to author
Forward
0 new messages