summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorHarry <hjwp2@cantab.net>2016-01-28 18:13:27 +0000
committerTim Graham <timograham@gmail.com>2016-02-01 13:41:31 -0500
commitfe41a134bcecd0fc7b6905a46bf055fca100fe28 (patch)
treefb1f2ad83ab8922cf971eb4f3eeb8033f0b886cf /docs
parent34fae0a4f7b0702cf9e4c72a8a3b82040a426595 (diff)
[1.9.x] Fixed #26152 -- Documented how to avoid django.setup() deadlock in standalone scripts.
Backport of 0fb1185538aeec9004fb9c84d96b81dc2778f66a from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/settings.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/topics/settings.txt b/docs/topics/settings.txt
index 70a4783da3..8b14d3ba52 100644
--- a/docs/topics/settings.txt
+++ b/docs/topics/settings.txt
@@ -291,6 +291,17 @@ 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.
+.. admonition:: ``django.setup()`` may only be called once.
+
+ Therefore, avoid putting reusable application logic in standalone scripts
+ so that you have to import from the script elsewhere in your application.
+ If you can't avoid that, put the call to ``django.setup()`` inside an
+ ``if`` block::
+
+ if __name__ == '__main__':
+ import django
+ django.setup()
+
.. seealso::
:doc:`The Settings Reference </ref/settings>`