Saturday, April 26, 2014

Loading data in migrations

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/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20140426155141.08babef1%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment