#23978: Migrations call callable field defaults only once for all rows
-------------------------------+--------------------
     Reporter:  rowanseymour   |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.7
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 If you add a field with a callable default to an existing model, e.g.

 {{{
 def generate_uuid():
     return unicode(uuid4())

 class Foo(models.Model):
     uuid = models.CharField(max_length=36, unique=True,
 default=generate_uuid)
 }}}

 You'll get a migration like...

 {{{
 migrations.AddField(
     model_name='foo',
     name='uuid',
     field=models.CharField(default=foo.models.generate_uuid,
 max_length=36, unique=True),
     preserve_default=True,
 ),
 }}}

 The default function is called only once to get a single default value for
 all rows, which in this case will fail because the column has a unique
 constraint.

--
Ticket URL: <https://code.djangoproject.com/ticket/23978>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.17d9660e64762778773251d0d1605a13%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to