﻿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
1437	[patch] Allow models to live outside models.py	Luke Plant	Adrian Holovaty	"In current magic-removal, you get exceptions if you want to place a model outside of the models.py module (e.g. in a subpackage) (to be specific, the check that the model is in INSTALLED_APPS throws an exception).  The attached patch fixes this by allowing 'module' to be specified as a 'Meta' option.  

Previously using 'app_label' would fix it.  By specifying 'module' instead, you won't need 'app_label' (in the usual case at least). Meta.module should be the fully qualified module name of the models file e.g. 'myproj.myapp.models', and you also need to import your model classes into {{{models.py}}} or {{{models/__init__.py}}}. 
 It looks like this:

{{{some_random_file.py}}}:
{{{
class Foo(models.Model):
    # fields etc
    class Meta:
        module = 'myapp.myproj.models'
}}}

{{{myapp/myproj/models.py}}} or {{{myapp/myproj/models/__init__.py}}}:
{{{
from some_random_file import Foo
}}}

I think that's relatively clean.  It only requires one line extra per model than what you would usually do i.e. the 'module' option in 'Meta'.
"	defect	closed	Metasystem	magic-removal	normal	invalid			Unreviewed	1	0	0	0	0	0
