From 2d876f8b3d1515b02fe3387af5a2912e61873065 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Jan 2015 04:23:45 +0100 Subject: [PATCH] WIP: workaround for content types, but not so much for auth Ref: https://github.com/alexhayes/django-migration-fixture/issues/1 --- django_migration_fixture/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django_migration_fixture/__init__.py b/django_migration_fixture/__init__.py index f867a76..2e175bb 100644 --- a/django_migration_fixture/__init__.py +++ b/django_migration_fixture/__init__.py @@ -1,6 +1,9 @@ import os from django.core import serializers +from django.contrib.contenttypes.management import update_all_contenttypes +from django.contrib.auth.management import create_permissions + class FixtureObjectDoesNotExist(Exception): """Raised when attempting to roll back a fixture and the instance can't be found""" @@ -36,6 +39,9 @@ def get_objects(): yield obj def load_fixture(apps, schema_editor): + update_all_contenttypes() + create_permissions(apps.get_app_config('auth'), verbosity=0) + for obj in get_objects(): obj.save() @@ -55,4 +61,4 @@ def unload_fixture(apps, schema_editor): if not raise_does_not_exist: raise FixtureObjectDoesNotExist("Model %s instance with kwargs %s does not exist." % (model, kwargs)) - return dict(code=load_fixture, reverse_code=unload_fixture) \ No newline at end of file + return dict(code=load_fixture, reverse_code=unload_fixture)