﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2260	[patch] Model tables get created in the wrong order	marcink@…	Adrian Holovaty	"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."	defect	closed	Database layer (models, ORM)	dev	normal	fixed		mir@…	Unreviewed	1	0	0	0	0	0
