Skip to content

Commit

Permalink
WIP: workaround for content types, but not so much for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jan 22, 2015
1 parent a293f57 commit 2d876f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion django_migration_fixture/__init__.py
Original file line number Diff line number Diff line change
@@ -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"""
Expand Down Expand Up @@ -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()

Expand All @@ -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)
return dict(code=load_fixture, reverse_code=unload_fixture)

0 comments on commit 2d876f8

Please sign in to comment.