[patch] Model tables get created in the wrong order
|Reported by:||Owned by:||Adrian Holovaty|
|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:5 Changed 10 years ago by
|Summary:||Model tables get created in the wrong order → [patch] Model tables get created in the wrong order|