I’m trying to migrate a few models from one Django app to another and based on this question How do I migrate a model out of one django app and into a new one? I’ve got it pretty much worked but when creating the first migration I’m getting this error:
"The model 'contenttype' from the app 'contenttypes' is not available in this migration."
Google and SO doesn’t seem to find any cases for this happening and the aforementioned question doesn’t have anything specific to say about it either, except the comment in the code:
if not db.dry_run:
# For permissions to work properly after migrating
orm['contenttypes.contenttype'].objects.filter(app_label='common', model='cat').update(app_label='specific')
Would really appreciate any insight into what am I doing wrong.
Here are the two migration files:
Create:
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
db.rename_table('cars_country', 'general_country')
if not db.dry_run:
# For permissions to work properly after migrating
orm['contenttypes.ContentType'].objects.filter(app_label='cars', model='country').update(app_label='general')
def backwards(self, orm):
pass
Delete:
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
depends_on = (
('general', '0002_create_country'),
)
def forwards(self, orm):
db.alter_column('cars_club', 'country_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['general.Country'], null=True))
def backwards(self, orm):
db.rename_table('general_country', 'cars_country')
db.alter_column('cars_club', 'country_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cars.Country'], null=True))