﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23978	Migrations call callable field defaults only once for all rows	Rowan Seymour	nobody	"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."	Bug	closed	Uncategorized	1.7	Normal	duplicate			Unreviewed	0	0	0	0	0	0
