The reason that b is needed is because if you modify the model afterwards,
loaddata will explode since the model is different.
Additionally, since migrations are now almost 10 times slower than with
south, nobody will want to create proper data migrations, so this is
really the best way to 'upgrade' from south.
--
Ticket URL: <https://code.djangoproject.com/ticket/22831>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* version: 1.7-beta-2 => master
* needs_docs: => 0
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted
Comment:
I agree there is no current "dumpdata" to get an initial data migration.
This would likely be helpful, and is a new feature. It's actually
orthogonal to updating from South - any situation where you would
previously have done a dumpdata > initial_data.json you now wish to do a
dumpdata > initial_migration. I think this feature is likely useful,
though the implementation is probably hard and I do not feel its absence
is a release blocking issue.
I'm concerned about your comments about migrations speed and upgrading
from South. However this ticket is now about adding a new feature to the
migrations framework - if you have concerns about migration's performance
please raise a separate ticket or open a discussion on django-dev.
--
Ticket URL: <https://code.djangoproject.com/ticket/22831#comment:1>
Comment (by gc@…):
The implementation should be trivial. Ours, granted, using mock, looks
like this:
{{{
def loaddata(app_registry, fixture_name):
from mock import patch
_get_model = app_registry.get_model
with patch('django.core.serializers.python._get_model', _get_model):
from django.core.management import call_command
call_command("loaddata", fixture_name)
}}}
Obviously, that's a hack, but in a more generic way, this get_model can be
passed all the way down to the serializer. Yeah, okay, maybe not exactly
trivial, but close enough.
As for the speed... I could open a discussion, sure, but tomorrow.
--
Ticket URL: <https://code.djangoproject.com/ticket/22831#comment:2>
Comment (by mardini):
#22608 covers migrations slow performance.
--
Ticket URL: <https://code.djangoproject.com/ticket/22831#comment:3>
* status: new => closed
* resolution: => wontfix
Comment:
I don't see what's being asked for here. Django 1.7 and migrations don't
support initial data fixtures, and in addition you're encouraged to do
data migrations using the ORM and RunPython rather than calling loaddata
(I don't want to have to make loaddata take an Apps object to get the
right set of models).
If you have existing South data migrations, you can literally do a find-
and-replace to make the same code work inside RunPython - just exchange
orm['app.Model'] for apps.get_model('app', 'model').
--
Ticket URL: <https://code.djangoproject.com/ticket/22831#comment:4>
Comment (by guettli):
Since this is closed as "wontfix" (which is ok for me), here is a guide
how to do this on your own:
http://stackoverflow.com/a/25981899/633961
--
Ticket URL: <https://code.djangoproject.com/ticket/22831#comment:5>
Comment (by MarkusH):
As luckily mentioned on Stackoverflow, all Django implementations that
rely on `django.core.serializers` **will not work reliably** in migrations
as that code will use the models from models.py and not from your
migration state!
--
Ticket URL: <https://code.djangoproject.com/ticket/22831#comment:6>