[patch] Model tables get created in the wrong order
|Reported by:||marcink@…||Owned by:||adrian|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Django's sqlreset sometimes generates CREATE statements in the wrong order.
My models.py file:
from django.db import models class AuctionElement(models.Model): name = models.CharField(maxlength=500) class AuctionDetails(models.Model): element = models.ForeignKey(AuctionElement) name = models.CharField(maxlength=500)
At least on my machine Django tries to create a table for AuctionDetails before AuctionElement. It might be difficult to reproduce since the result depends on model names: change them a bit and you will get different order.
As far as I can tell Django neither keeps track of model sequence nor tries to order them by dependencies. The order as defined in models.py is lost in db.models.loading.register_models.
Change History (8)
comment:4 Changed 10 years ago by marcink@…
- Resolution fixed deleted
- Status changed from closed to reopened
- Version set to SVN
Changed 10 years ago by marcink@…
comment:5 Changed 10 years ago by marcink@…
- Summary changed from Model tables get created in the wrong order to [patch] Model tables get created in the wrong order
comment:6 Changed 10 years ago by mtredinnick
- Resolution set to fixed
- Status changed from reopened to closed