Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django-South DataMigration - App available in forwards() but not backwards()?

I am writing a django south migration that depends on the model in another app, so I have included --freeze OTHERAPPNAME when I ran python manage.py datamigration …

However in the forwards() function I can access the other model fine (with orm['otherappname.MyModelName']), however in the backwards() step (which also depends on the model in otherappname), if I try to access orm['otherappname.MyModelName'], I get an error

*** KeyError: "The model 'mymodelname' from the app 'otherappname' is not available in this migration."

I can see the frozen model details in the bottom of the file. Why can't I access it?

NB: This model is created in another migration inside otherappname of which this datamigration depends on.

like image 843
Amandasaurus Avatar asked Mar 02 '12 16:03

Amandasaurus


1 Answers

The backwards migration actually uses the frozen ORM of the previous migration. It's logical when you think about it, but it's admittedly not very intuitive.

Moral: freeze the models you'll need in your datamigration in the schemamigration that proceeds it.

like image 157
Chris Pratt Avatar answered Sep 18 '22 23:09

Chris Pratt