Django 1.8 Migrations: AlterField Migration calls default callable for ForeignKey even when no Model Instances Exist

48 views
Skip to first unread message

Dylan Young

unread,
Mar 14, 2017, 12:50:52 PM3/14/17
to django-d...@googlegroups.com
Steps to reproduce:

Create Model
Make migrations
Add FK to model with a callable default that has some side effect (e.g. creating the default instance in the database)
Make migrations
Migrate (or run tests on clean db)
Observe the side effect


I couldn't find this on the Bug Tracker. Is this still an issue in dev branch?

I haven't reproduced in a controlled test, but if this is something that others have observed or think may be an issue, I can look into reproducing cleanly.

If this is the intended behaviour then documentation is needed, though I don't see why it would be since defaults aren't enforced on the DB level.  

Note: it runs cleanly if the default is placed in an AddField migration. 

Best,

Casey Meijer   

Tim Graham

unread,
Mar 14, 2017, 2:42:40 PM3/14/17
to Django developers (Contributions to Django itself)
Hi, I think the issue is described in https://code.djangoproject.com/ticket/24182.
Reply all
Reply to author
Forward
0 new messages