cannot instantiate a stub model

2 views
Skip to first unread message

greg.newman

unread,
May 7, 2009, 10:42:01 AM5/7/09
to South Users
I'm trying to run a custom migration:

class Migration:

no_dry_run = True

def forwards(self, orm):
"Write your forwards migration here"
for show in orm.Show.objects.all():
show.hotel_package_avail=False
show.save()

But I get the following error:

"You cannot instantiate a stub model"

Any idea why? I can't find any reference to this in the groups or
documentation.

Andrew Godwin

unread,
May 8, 2009, 1:07:33 PM5/8/09
to south...@googlegroups.com
This usually means that the Show model is frozen as a 'stub', not a full
model, which is certainly unusual - South defaults to freezing the
entire application. Three questions:

- Does your settings.py have SOUTH_AUTO_FREEZE_APP = True in it?
- Is the 'Show' model in a different app to the migration?
- If you answered 'no' to both the above, what's the models dict on
your migration look like?

Andrew

Rasiel

unread,
Jun 18, 2009, 1:46:35 PM6/18/09
to South Users
Hi Andrew,

i answered no to both your questions above, as i have the same issue,
my models dict looks like this below:

models = {
'realestate.realestatelisting': {
'address': ('models.CharField', [], {'max_length':
'100'}),
'bathrooms': ('models.CharField', [], {'blank': 'True',
'max_length': '100', 'null': 'True'}),
'bedrooms': ('models.CharField', [], {'blank': 'True',
'max_length': '100', 'null': 'True'}),
'building_size': ('models.CharField', [], {'max_length':
'50', 'null': 'True', 'blank': 'True'}),
'community_features': ('models.ManyToManyField', ["orm
['realestate.Feature']"], {'related_name': '"community_features"',
'null': 'True', 'blank': 'True'}),
'contact_person': ('models.ForeignKey', ["orm
['logistics.ContactPerson']"], {'related_name':
'"realestate_contact_person"'}),
'date_added': ('models.DateField', [], {'auto_now_add':
'True', 'editable': 'False'}),
'description': ('models.TextField', [], {}),
'display_picture': ('models.ForeignKey', ["orm
['upload.FileUpload']"], {'null': 'True', 'blank': 'True'}),
'expiration_date': ('models.DateField', [], {}),
'featured_on_homepage': ('models.BooleanField', [], {}),
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'image_gallery': ('models.ForeignKey', ["orm
['media.ImageGallery']"], {'null': 'True', 'blank': 'True'}),
'listing_type': ('models.ForeignKey', ["orm
['realestate.RealEstateType']"], {'related_name': '"listing_type"'}),
'location': ('models.ForeignKey', ["orm
['logistics.Location']"], {'related_name': '"realestate_location"'}),
'lot_size': ('models.CharField', [], {'max_length': '50',
'null': 'True', 'blank': 'True'}),
'not_permitted': ('models.ManyToManyField', ["orm
['realestate.NotAllowed']"], {'null': 'True', 'blank': 'True'}),
'price': ('models.DecimalField', [], {'max_digits': '10',
'decimal_places': '2'}),
'pricing_option': ('models.ForeignKey', ["orm
['realestate.PricingOption']"], {'related_name':
'"realeastate_pricing_options"'}),
'property_facilities': ('models.ManyToManyField', ["orm
['realestate.Facilities']"], {'null': 'True', 'blank': 'True'}),
'property_features': ('models.ManyToManyField', ["orm
['realestate.Feature']"], {'related_name': '"property_features"',
'null': 'True', 'blank': 'True'}),
'secondary_contact': ('models.ForeignKey', ["orm
['logistics.ContactPerson']"], {'related_name':
'"realestate_secondary_contact"', 'null': 'True', 'blank': 'True'}),
'slug_url': ('models.SlugField', [], {}),
'status': ('models.CharField', [], {'default': "'1'",
'max_length': '2'}),
'title': ('models.CharField', [], {'max_length': '100'}),
'video_gallery': ('models.ForeignKey', ["orm
['media.VideoGallery']"], {'null': 'True', 'blank': 'True'})
},
'realestate.pricingoption': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'media.videogallery': {
'_stub': True,
'id': ('models.AutoField', [], {'primary_key': 'True'})
},
'listings.listingtype': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'}),
'slug_url': ('models.SlugField', [], {})
},
'logistics.location': {
'_stub': True,
'id': ('models.AutoField', [], {'primary_key': 'True'})
},
'listings.restriction': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'realestate.notallowed': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'listings.pricingoption': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'media.imagegallery': {
'_stub': True,
'id': ('models.AutoField', [], {'primary_key': 'True'})
},
'logistics.contactperson': {
'_stub': True,
'id': ('models.AutoField', [], {'primary_key': 'True'})
},
'listings.listing': {
'address': ('models.CharField', [], {'max_length':
'100'}),
'contact_person': ('models.ForeignKey', ["orm
['logistics.ContactPerson']"], {'related_name':
'"listings_contact_person"'}),
'date_added': ('models.DateField', [], {'auto_now_add':
'True', 'editable': 'False'}),
'description': ('models.TextField', [], {}),
'display_picture': ('models.ForeignKey', ["orm
['upload.FileUpload']"], {'null': 'True', 'blank': 'True'}),
'expiration_date': ('models.DateField', [], {}),
'featured_on_homepage': ('models.BooleanField', [], {}),
'features': ('models.ManyToManyField', ["orm
['listings.Feature']"], {'related_name':
'"listings_property_features"', 'null': 'True', 'blank': 'True'}),
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'image_gallery': ('models.ForeignKey', ["orm
['media.ImageGallery']"], {'null': 'True', 'blank': 'True'}),
'listing_type': ('models.ForeignKey', ["orm
['listings.ListingType']"], {'related_name': '"listing_type"'}),
'location': ('models.ForeignKey', ["orm
['logistics.Location']"], {'related_name': '"listings_location"'}),
'price': ('models.DecimalField', [], {'max_digits': '10',
'decimal_places': '2'}),
'pricing_option': ('models.ForeignKey', ["orm
['listings.PricingOption']"], {'related_name':
'"listings_pricing_options"'}),
'restrictions': ('models.ManyToManyField', ["orm
['listings.Restriction']"], {'null': 'True', 'blank': 'True'}),
'secondary_contact': ('models.ForeignKey', ["orm
['logistics.ContactPerson']"], {'related_name':
'"listings_secondary_contact"', 'null': 'True', 'blank': 'True'}),
'slug_url': ('models.SlugField', [], {}),
'status': ('models.CharField', [], {'default': "'1'",
'max_length': '2'}),
'sub_type': ('models.ForeignKey', ["orm
['listings.SubType']"], {'related_name': '"listing_sub_type"'}),
'title': ('models.CharField', [], {'max_length': '100'})
},
'realestate.realestatetype': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'realestate.feature': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'listings.subtype': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'}),
'parent': ('models.ForeignKey', ["orm
['listings.ListingType']"], {}),
'slug_url': ('models.SlugField', [], {})
},
'realestate.facilities': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
},
'upload.fileupload': {
'Meta': {'ordering': "['upload_date','title']"},
'_stub': True,
'id': ('models.AutoField', [], {'primary_key': 'True'})
},
'listings.feature': {
'id': ('models.AutoField', [], {'primary_key': 'True'}),
'name': ('models.CharField', [], {'max_length': '50'})
}
}

complete_apps = ['listings', 'realestate']

and my migration looks like this:

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=listing.listing_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)

thanks for the help

On May 8, 11:07 am, Andrew Godwin <and...@aeracode.org> wrote:
> This usually means that the Showmodelis frozen as a 'stub', not a fullmodel, which is certainly unusual - South defaults to freezing the
> entire application. Three questions:
>
>  - Does your settings.py have SOUTH_AUTO_FREEZE_APP = True in it?
>  - Is the 'Show'modelin a different app to the migration?
Reply all
Reply to author
Forward
0 new messages