Multi-table Models and Fixtures
|Reported by:||Greg Taylor||Owned by:||nobody|
|Severity:||Keywords:||model, inheritance, subclass, fixture|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
It seems like multi-table sub-classed models (not abstract) don't
honor the "pk" being specified in fixtures. For example, I have an
Event class that is sub-classed by a Race model. The Event class is in
an app called "calendar" and the Race model is in an app called
"regattas". I dumpdata regattas, reset both apps, and loaddata the
regattas fixture. It loads properly but all of the PKs are now
sequential, meaning a lot of other models are now pointing at the
wrong regatta primary keys. There were regattas with PK IDs 14, 16, and 18, but
are now 1, 2, and 3. I have confirmed that the fixture contains the
old 14, 16, and 18 primary keys.
The problem is the keys seem to be compacted rather than being loaded
from the fixture. The keys are not always uninterrupted sequences of numbers due to deletes.
So the problem doesn't exhibit itself until you delete, dumpdata, then
try to re-load.