summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-01-19 09:35:59 -0500
committerTim Graham <timograham@gmail.com>2014-01-19 09:35:59 -0500
commit5c7ac7494ab5f1cdc364f829f61ffef85ad7344b (patch)
treed4272a256a2a4d4c37b92e5b494018043a55b7fb /docs
parent66f546b90624297858b0f958abbe5c2b3e8bdffb (diff)
Fixed #18907 -- Correct docs regard population of model backrefs.
Thanks simonpercivall for the report and Aymeric for the patch.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/queries.txt15
1 files changed, 10 insertions, 5 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 7f04c66fcb..94073d1a70 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -1280,11 +1280,16 @@ relationship on one end.
But how is this possible, given that a model class doesn't know which other
model classes are related to it until those other model classes are loaded?
-The answer lies in the :setting:`INSTALLED_APPS` setting. The first time any
-model is loaded, Django iterates over every model in :setting:`INSTALLED_APPS`
-and creates the backward relationships in memory as needed. Essentially, one of
-the functions of :setting:`INSTALLED_APPS` is to tell Django the entire model
-domain.
+The answer lies in the :data:`app registry <django.apps.apps>`. When Django
+starts, it imports each application listed in :setting:`INSTALLED_APPS`, and
+then the ``models`` module inside each application. Whenever a new model class
+is created, Django adds backward-relationships to any related models. If the
+related models haven't been imported yet, Django keeps tracks of the
+relationships and adds them when the related models eventually are imported.
+
+For this reason, it's particularly important that all the models you're using
+be defined in applications listed in :setting:`INSTALLED_APPS`. Otherwise,
+backwards relations may not work properly.
Queries over related objects
----------------------------