﻿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
25127	document how to define models in multiple modules	Kevin Turner	Evan Palmer	"Though recent versions of Django have taken steps to support the ability have a number of models organized in a `models/` package instead of a single `models.py` file, the Models documentation topic does not give guidance on how to do this.

Searching the web for answers turns up a lot of 2009-era results, which I believe are misleading when applied to current versions of Django.

There is a [https://code.djangoproject.com/wiki/CookBookSplitModelsToFiles cookbook entry] which looks at least halfway current.

Statements I've seen (which I think are now questionable) are:

* If your models are not in `models.py`, you have to explicitly set `db_table` on each model.
* ...you have to explicitly set `app_label` on each model
* in `models.py` or `models/__init__.py` you have to `import *` from each module where you define models

There's this statement in the [https://docs.djangoproject.com/en/1.7/releases/1.7/#app-loading-refactor Django 1.7 release notes]:

> Application labels are assigned correctly to models even when they’re defined outside of models.py. You don’t have to set app_label explicitly any more.

which makes me think all of those things may be obsolete. Are there any constraints on where you define models now? If they're not in `models.py`, what do you need to do to ensure they're loaded?

Documentation on the [https://docs.djangoproject.com/en/dev/ref/applications/#initialization-process app initilaization process] still says the app's `models` module or package is loaded, so maybe that ""you must `import *` in your `models.py` or `models/__init__.py`"" thing is still true?
"	Cleanup/optimization	closed	Documentation	1.8	Normal	fixed			Accepted	1	0	0	0	0	0
