﻿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
3688	[patch] Improve support for mutually-referential models	Ben Slavin <benjamin.slavin@…>	Adrian Holovaty	"!ForeignKey and other related model fields allow recursive relationships; however, there can be problems when dealing with mutually referential models.

For example, consider a user class and a series of articles:
{{{
#!python
class User(models.Model):
    saved_articles = models.ManyToManyField('Article')
    # ...

class Article(models.Model):
    author = models.ForeignKey(User)
    # ...
}}}

It doesn't make much sense for ''User''s and ''Article''s to be stored in the same
models.py file.

By using dotted-notation (''app_name.model_name''), it should be
possible to reference across models.py files when recursive ''import''
statements would otherwise cause problems.

'''my_project/accounts/models.py'''
{{{
#!python
class User(models.Model):
    saved_articles = models.ManyToManyField('articles.Article')
    # ...
}}}
'''my_project/articles/models.py'''
{{{
#!python
class Article(models.Model):
    author = models.ForeignKey('accounts.User')
    # ...
}}}

Attached patch adds this functionality and provides documentation."		closed	Core (Other)	dev		fixed			Unreviewed	1	0	0	0	0	0
