Ticket #123 (closed defect: fixed)
Problems when (apparently) models file is split into submodules
|Reported by:||miracle2k||Owned by:||andrew|
I've split my models.py file into submodules, one for each model, and South gives me the following error when trying to do an initial freeze:
AssertionError?: ForeignKey?(<module 'apps.database.models.feed' from '/Users/melsdoerfer/Documents/Dev/Projects/mine/podster/web/podster/apps/database/models/feed.pyc'>) is invalid. First parameter to ForeignKey? must be either a model, a model name, or the string 'self'
Stepping through the code, here's what seems to be happening:
1) eval_in_context() builds a fake_locals dict and starts out with both 'feed' (the module) and 'Feed' (the model).
2) The model gets removed.
3) The fake models are added, lower-cased, but the feed model is not.
4) ModelsLocals?() makes 'Feed' fallback to 'feed'.
The problem is in step 3: The fake Feed model is not being added. The reason might be that the order in which the frozen models are defined in the migration is incorrect (changing the order did fix the issue for me). Initially, I thought the fact that I am using submodules means South doesn't know what the right order is, but considering that the models-attribute of the migration is an unordered dict in the first place, I'm no longer sure if that can be considered the problem.
- Status changed from new to assigned
- Version set to subversion
- Milestone set to 0.5