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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With