0

I am trying to access the Flatpages models in a South migration like so:

s = orm['flatpages.Site'].objects.get(id=10)
f = orm['flatpages.FlatPage'].objects.get(id=10)

I get errors saying that site and flatpage models are not available in the flatpages app. So what am I doing wrong?

Alex
  • 1,891
  • 3
  • 23
  • 39

1 Answers1

0

You can't access it via South's orm object, but you can break the recommendation and import the model directly if you're simply looking to force a data migration, e.g.,

from south.db import db
from south.v2 import DataMigration
from django.db import models

from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site

class Migration(DataMigration):

    def forwards(self, orm):
        site = Site.objects.get_current()
        f = FlatPage.objects.create(
            title="Page Name",
            url="/url/",
            content="..."
        )
        f.sites.add(site)
        f.save()
Tom
  • 22,301
  • 5
  • 63
  • 96
  • This is the way I ended up doing it but it is frowned upon according to the South docs and comments that are generated in the migration. – Alex Aug 27 '14 at 14:55