Loading data in migrations

25 views
Skip to first unread message

Tim Chase

unread,
Apr 26, 2014, 4:51:41 PM4/26/14
to django...@googlegroups.com
According to [1]

"""
[automatically loading initial data via fixtures is d]eprecated since
version 1.7: If an application uses migrations, there is no automatic
loading of fixtures. Since migrations will be required for
applications in Django 1.9, this behavior is considered deprecated.
If you want to load initial data for an app, consider doing it in a
migration.
"""

However, the docs don't link to how that data should be furnished to
the migration. As best I can tell from reading[2], it sounds like
one needs to create a Python function that creates & saves the data,
and then provide that function to migrations.RunPython to be
executed. Is this correct, or is there some easier way to provide
that initial data to an app?

Thanks,

-tkc

[1]
https://docs.djangoproject.com/en/dev/howto/initial-data/#automatically-loading-initial-data-fixtures

[2]
https://docs.djangoproject.com/en/dev/topics/migrations/

J Y

unread,
May 6, 2014, 12:20:57 PM5/6/14
to django...@googlegroups.com, django...@tim.thechases.com
I would like to know this also.  Can anyone provide an example of how to do this in 1.7?  The doc leaves a lot to the imagination.  I'd be willing to help update the docs if there's guidance on what the official "sanctioned" approach is to replicate the same functionality, that behaves like the initial_data files.
Reply all
Reply to author
Forward
0 new messages