﻿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
13366	Model importing race condition created in [12977] for subclasses of abstract classes that have fields.	Brett Hoerner	nobody	"We ran into a weird edge case race condition that seems to be caused by [12977].  FWIW I haven't taken all the time needed to understand exactly why or what [12977] does, I'm just reporting the error based on a traceback and example code set. :)

Basic things you need:

 1. An abstract base class with a field, and a model A that uses it, so that {{{ModelBase.__new__}}} will drop into the ""{{{new_class.add_to_class(field.name, copy.deepcopy(field))}}}"" branch intended for abstract only.
 2. Another model (in a different module) that imports model A.
 3. A management command that imports model A (this won't happen in the shell, I'm not sure what the difference is yet or where else it would occur).

Basically it seems that the new ""{{{self.default = self.model._meta.get_field_by_name(self.name)[0].default}}}"" results eventually in a ""{{{get_models()}}}"", but this is run *while model A is being loaded* which means that all models are fetched, including the models file which contains model B and thus imports model A, and then blammo, circular dependency problem.

I've attached a simple project with two apps and a sample management command."		closed	Core (Other)	dev		fixed		adulic@… safariman@… davisd.davisd@… rokclimb15@…	Accepted	0	0	0	0	0	0
