﻿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
14705	Model Field Order not influenced by MRO of superclasses	Klaas van Schelven	nobody	"Looking at the two definitions below, 

{{{
class OneTwo(AbstractModelOne, AbstractModelTwo):
    pass

class TwoOne(AbstractModelTwo, AbstractModelOne):
    pass
}}}

one (I?) would expect the order of the fields in the second definition to be the opposite of the order in the first one. (Since the base classes are referenced in the opposite order). This is, however, not the case. 

Django only uses creation_counter to determine the order of the fields. Therefor the actual field order is determined by the order in which the containing abstract classes are evaluated (i.e. their python code is read). If these classes come from multiple sources (apps) the field order may end up to be pretty much random (though deterministic).

The general use case is heavy use of abstract models to mix in information from various sources into actual models. In real apps the two above models are not very likely, but being able to have control over the field order (other than placing the abstract models in a certain order) is important.
I make heavy use abstract models to be able to make my apps reusable. The above situation is an important roadblock to efficient use.

A patch with a failing test is attached.
Haven't yet been able to fix this in a non-intrusive way.
I would be very much obliged if someone can come up with a solution."	New feature	new	Database layer (models, ORM)	dev	Normal			lrekucki@…	Accepted	1	0	0	1	0	0
