summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-01-10 23:06:19 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-01-10 23:43:10 +0100
commit3326a412ccde9f72e22a070a0b4d922048ed2286 (patch)
tree7583ee99e53ab3d3bf846f1aec79dc34d330d2cf /docs
parent81bb8d12209a419142b1bf6961fbf9fc44419dcd (diff)
Deprecated importing a model before loading its application.
Refs #21719, #21680.
Diffstat (limited to 'docs')
-rw-r--r--docs/internals/deprecation.txt6
-rw-r--r--docs/ref/applications.txt7
-rw-r--r--docs/releases/1.7.txt15
3 files changed, 25 insertions, 3 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 1b8b45a520..514561e1ff 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -170,6 +170,12 @@ these changes.
* ``allow_syncdb`` on database routers will no longer automatically become
``allow_migrate``.
+* All models will need to be defined inside an installed application or
+ declare an explicit :attr:`~django.db.models.Options.app_label`.
+ Furthermore, it won't be possible to import them before their application
+ is loaded. In particular, it won't be possible to import models inside
+ the root package of their application.
+
* If models are organized in a package, Django will no longer look for
:ref:`initial SQL data<initial-sql>` in ``myapp/models/sql/``. Move your
custom SQL files to ``myapp/sql/``.
diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt
index a44062808e..e496f24487 100644
--- a/docs/ref/applications.txt
+++ b/docs/ref/applications.txt
@@ -181,6 +181,13 @@ Methods
as registering signals. It is called as soon as the registry is fully
populated.
+ You cannot import models in modules that define application configuration
+ classes, but you can use :meth:`get_model` to access a model class by
+ name, like this::
+
+ def ready(self):
+ MyModel = self.get_model('MyModel')
+
Application registry
====================
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index a8becf1bab..9fcad38931 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -677,9 +677,18 @@ directory and a subdirectory on :envvar:`PYTHONPATH`. Refer to the section on
the new project layout in the :doc:`1.4 release notes </releases/1.4>` for
migration instructions.
-You should make sure that your project doesn't import models from applications
-that aren't in :setting:`INSTALLED_APPS`. Relations involving such models may
-not be created properly. Future versions of Django may forbid this entirely.
+You should make sure that:
+
+* All models are defined in applications that are listed in
+ :setting:`INSTALLED_APPS` or have an explicit
+ :attr:`~django.db.models.Options.app_label`.
+
+* Models aren't imported as a side-effect of loading their application.
+ Specifically, you shouldn't import models in the root module of an
+ application nor in the module that define its configuration class.
+
+Django will enforce these requirements as of version 1.9, after a deprecation
+period.
Subclassing AppCommand
^^^^^^^^^^^^^^^^^^^^^^