Don't fail if the taggit app is not installed

This commit is contained in:
Roberto Rosario
2014-10-17 22:48:16 -04:00
parent ac5adbdc3f
commit 9a164d6bd3

View File

@@ -4,8 +4,6 @@ from south.db import db
from south.v2 import DataMigration
from django.db import models
from taggit.models import Tag as TaggitModel
class Migration(DataMigration):
def forwards(self, orm):
@@ -14,9 +12,14 @@ class Migration(DataMigration):
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.
for tag in TaggitModel.objects.all():
color = orm.TagProperties.objects.get(tag=tag).color
orm.Tag.objects.create(label=tag.name, color=color)
try:
from taggit.models import Tag as TaggitModel
except ImportError:
pass
else:
for tag in TaggitModel.objects.all():
color = orm.TagProperties.objects.get(tag=tag).color
orm.Tag.objects.create(label=tag.name, color=color)
def backwards(self, orm):
"Write your backwards methods here."