155👍
import settings
will import the first python module named settings.py
found in sys.path
. Usually (in default django setups) it allows access only to your site defined settings file, which overwrites django default settings (django.conf.global_settings
).
So, if you try to access a valid django setting not specified in your settings file you will get an error.
django.conf.settings
is not a file but an object (see source) making an abstraction of the concepts, default settings and your site-specific settings. Django also does other checks when you use from django.conf import settings
.
You can also find it in the django docs.
37👍
from django.conf import settings
is better option.
I use different settings files for the same django project (one for “live”, one for “dev”), the first one will select the one being executed.
- [Django]-Copy a database column into another in Django
- [Django]-Django: Reference to an outer query may only be used in a subquery
- [Django]-Django – what is the difference between render(), render_to_response() and direct_to_template()?