Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using the 'loaddata' management command in a data migration with South is going to break things as soon as the used models change in any way (when running the migrations on a fresh install). The data loaders don't know about the frozen ORM provided by South but use the current state of the models as in the respective ''. Here's a fixtur…
from myproject.utils import loaddata
class Migration(DataMigration):
def forwards(self, orm):
loaddata(orm, 'some_fancy_fixture.json')
def loaddata(orm, fixture_name):
Overwrite the ``_get_model`` command in the serialiser to use the
FakeORM model from south instead of the latest model.
from dingus import patch
_get_model = lambda model_identifier: orm[model_identifier]
with patch('django.core.serializers.python._get_model', _get_model):
from import call_command
call_command("loaddata", fixture_name)
Copy link

codeinthehole commented Jul 26, 2013

Ha - nice workaround

Copy link

npardington commented Sep 5, 2013

Thanks for this workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment