#25007: UUIDFIeld(default=uuid.uuid4) created with migrations are the same ----------------------------+----------------------------------------- Reporter: afg984 | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 1.8 Severity: Normal | Keywords: migrations, uuid, UUIDField Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+----------------------------------------- Steps to reproduce:
1. Create model {{{#!python class Bar(models.Model): pass }}} 2. makemigrations & migrate 3. Create some Bar()s in the database {{{#!python >>> Bar.objects.create() <Bar: Bar object> >>> Bar.objects.create() <Bar: Bar object> >>> Bar.objects.create() <Bar: Bar object> >>> Bar.objects.create() <Bar: Bar object> }}} 4. Add a UUIDField {{{#!python class Bar(models.Model): uu = models.UUIDField(default=uuid.uuid4) }}} 5. makemigrations & migrate if I use `unique=True` in the previous step, `./manage.py migrate` gives me: {{{django.db.utils.IntegrityError: UNIQUE constraint failed: foo_bar__new.uu}}} 6. The UUIDs are the same {{{#!python >>> [bar.uu for bar in Bar.objects.all()] [UUID('fae77227-7555-457d-a049-1e62e030ce1c'), UUID('fae77227-7555-457d-a049-1e62e030ce1c'), UUID('fae77227-7555-457d-a049-1e62e030ce1c'), UUID('fae77227-7555-457d-a049-1e62e030ce1c')] }}} Environment: {{{#!python >>> platform.python_version() '3.4.3' >>> platform.platform() 'Linux-4.0.5-1-ARCH-x86_64-with-arch' >>> django.__version__ '1.8.2' }}} -- Ticket URL: <https://code.djangoproject.com/ticket/25007> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.9a8317b39b98e9e9cbeda2fa0a030c19%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.