[Django] #23988: Fixtures should be loaded after migrations

7 views
Skip to first unread message

Django

unread,
Dec 12, 2014, 11:20:19 PM12/12/14
to django-...@googlegroups.com
#23988: Fixtures should be loaded after migrations
----------------------------+--------------------
Reporter: yuriiz | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
It is currently not possible to add data for apps that have migrations in
fixtures/initial_data.json because migrate command loads fixtures after
syncdb but before migrations i.e. when required tables do not exist yet.
For example if one adds data for flatpages app in fixtures/initial_data
like this:

{{{
{
"fields": {
"registration_required": false,
"title": "foo",
"url": "/url/",
"template_name": "",
"sites": [1],
"content": "bar",
"enable_comments": false
},
"model": "flatpages.flatpage",
"pk": 1
}
}}}
running "manage.py migrate" on new DB will result in:

{{{
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: Problem installing fixture
'/home/user/project/fixtures/initial_data.json': Could not load
flatpages.FlatPage(pk=1): no such table: django_flatpage
}}}
This breaks DB creation on "manage.py test" as well.
Correct behaviour would be to install initial_data.json AFTER tables for
apps with migrations are created as well.

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

Django

unread,
Dec 15, 2014, 1:55:11 PM12/15/14
to django-...@googlegroups.com
#23988: Fixtures should be loaded after migrations
----------------------------+--------------------------------------
Reporter: yuriiz | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

Initial data isn't supported for apps with migrations, see
https://docs.djangoproject.com/en/1.7/howto/initial-data/#automatically-
loading-initial-data-fixtures.

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

Reply all
Reply to author
Forward
0 new messages