views:

136

answers:

1

so i'm trying to do a data migration where i take the "listings" from a realestate app into a new "listings" app that i've created.

i did startmigration like this:

python manage.py startmigration listings migrate_listings --freeze realestate

created a blank migration, which i populated with this:

def forwards(self, orm):
        "Write your forwards migration here"
        for listing in orm['realestate.RealEstateListing'].objects.all():
            sub_type = orm.SubType.objects.get(slug_url=slugify(listing.listing_type.name))
            lt = orm.Listing(listing_type=sub_type.parent,
                             sub_type=sub_type,
                             expiration_date=listing.expiration_date,
                             title=listing.title,
                             slug_url = listing.slug_url,
                             description = listing.description,
                             contact_person=listing.contact_person,
                             secondary_contact=listing.secondary_contact,
                             address=listing.address,
                             location=listing.location,
                             price=listing.price,
                             pricing_option=listing.pricing_option,
                             display_picture=listing.display_picture,
                             image_gallery=listing.image_gallery,
                             date_added=listing.date_added,
                             status=listing.status,
                             featured_on_homepage=listing.featured_on_homepage,
                             )
            lt.save()

            lt.features.clear()
            for ft in listing.property_features.all:
                lt.features.add(ft)

            for cft in listing.community_features.all:
                lt.features.add(cft)

            lt.restrictions.clear()    
            for na in listing.not_allowed.all:
                lt.restrictions.add(na)

however when i run the migration is still get this error:

whiney_method

ValueError("you cannot instantiate a stub model")

from what i understand you can't access a "stub" model using the fakeorm but freezing additional apps is not allowed. how do i go about using the "stub" models without freezing them?

+2  A: 

ok so i'm answering my own question, since apparantly i'm the only django south user here. i had to figure it out by myself.

what i wasn't doing, was freezing all the apps that were required in the above migration. since i didn't freeze it created the stub models.

the proper syntax for freezing multiple apps is:

python manage.py startmigration listings migrate_listings --freeze realestate --freeze logistics --freeze media --freeze upload

and everything works after that!

Rasiel