summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJames Bennett <james@b-list.org>2015-07-21 12:12:42 -0500
committerTim Graham <timograham@gmail.com>2015-07-21 17:10:17 -0400
commit5281f8b635f10b2839dc146d7e44f7d94d1955d8 (patch)
tree75e0ec17fac3802f568285d769ee123f99a0f080 /docs
parent59c279e5e55de51640f7136063bc1880f2ad72d1 (diff)
Fixed #25156 -- Mentioned django.setup() in the settings overview for standalone Django use.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/settings.txt24
1 files changed, 23 insertions, 1 deletions
diff --git a/docs/topics/settings.txt b/docs/topics/settings.txt
index 6caeff186a..2d44a84364 100644
--- a/docs/topics/settings.txt
+++ b/docs/topics/settings.txt
@@ -265,7 +265,29 @@ Also, it's an error to call ``configure()`` more than once, or to call
It boils down to this: Use exactly one of either ``configure()`` or
``DJANGO_SETTINGS_MODULE``. Not both, and not neither.
-.. _@login_required: ../authentication/#the-login-required-decorator
+Calling ``django.setup()`` is required for "standalone" Django usage
+--------------------------------------------------------------------
+
+If you're using components of Django "standalone" -- for example, writing a
+Python script which loads some Django templates and renders them, or uses the
+ORM to fetch some data -- there's one more step you'll need in addition to
+configuring settings.
+
+After you've either set :envvar:`DJANGO_SETTINGS_MODULE` or called
+``configure()``, you'll need to call :func:`django.setup()` to load your
+settings and populate Django's application registry. For example::
+
+ from django.conf import settings
+ from myapp import myapp_defaults
+
+ settings.configure(default_settings=myapp_defaults, DEBUG=True)
+ django.setup()
+
+ # Now this script can use any part of Django it needs.
+
+Note that calling ``django.setup()`` is only necessary if your code is truly
+standalone. When invoked by your Web server, or through :doc:`django-admin
+</ref/django-admin>`, Django will handle this for you.
.. seealso::