Fixed #2274 -- Fixed error in settings documentation. Thanks, Le Roux Bodenstein
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3252 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bd6a758e5c
commit
e37bb07bc6
|
@ -107,15 +107,20 @@ For more, see the `diffsettings documentation`_.
|
||||||
Using settings in Python code
|
Using settings in Python code
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
In your Django apps, use settings by importing them from
|
In your Django apps, use settings by importing the object
|
||||||
``django.conf.settings``. Example::
|
``django.conf.settings``. Example::
|
||||||
|
|
||||||
from django.conf.settings import DEBUG
|
from django.conf import settings
|
||||||
|
|
||||||
if DEBUG:
|
if settings.DEBUG:
|
||||||
# Do something
|
# Do something
|
||||||
|
|
||||||
Note that your code should *not* import from either ``global_settings`` or
|
Note that ``django.conf.settings`` isn't a module -- it's an object. So
|
||||||
|
importing individual settings is not possible::
|
||||||
|
|
||||||
|
from django.conf.settings import DEBUG # This won't work.
|
||||||
|
|
||||||
|
Also note that your code should *not* import from either ``global_settings`` or
|
||||||
your own settings file. ``django.conf.settings`` abstracts the concepts of
|
your own settings file. ``django.conf.settings`` abstracts the concepts of
|
||||||
default settings and site-specific settings; it presents a single interface.
|
default settings and site-specific settings; it presents a single interface.
|
||||||
It also decouples the code that uses settings from the location of your
|
It also decouples the code that uses settings from the location of your
|
||||||
|
@ -127,9 +132,9 @@ Altering settings at runtime
|
||||||
You shouldn't alter settings in your applications at runtime. For example,
|
You shouldn't alter settings in your applications at runtime. For example,
|
||||||
don't do this in a view::
|
don't do this in a view::
|
||||||
|
|
||||||
from django.conf.settings import DEBUG
|
from django.conf import settings
|
||||||
|
|
||||||
DEBUG = True # Don't do this!
|
settings.DEBUG = True # Don't do this!
|
||||||
|
|
||||||
The only place you should assign to settings is in a settings file.
|
The only place you should assign to settings is in a settings file.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue