4
It doesnβt work because your forget the .
in front of local_settings.py
(relative import). Try from .local_settings.py import *
, also check that there is an __init__.py
in the current folder.
Concerning settings, I recommend you to store your settings in a settings
folder. And create a setting file for each environment. Create a base.py
file, which contains base settings and then import it in all other settings files.
Here is the structure :
βββ project_name
β βββ project_name
β β βββ settings
β β β βββ __init__.py
β β β βββ base.py
β β β βββ dev.py
β β β βββ staging.py
β β β βββ prod.py
β β βββ __init__.py
β β βββ urls.py
β β βββ wsgi.py
...
And a settings file (E.g :dev.py
or local.py
) :
try:
from .base import *
except ImportError:
print('Unable to import base settings file:')
# ...
Use always relative imports when itβs possible.
Concerning databases, you shouldnβt configure them in base.py
. Declare them in each specific settings files.
2
from rororo.settings import inject_settings
in the end of yourβs settings.py
inject_settings('settings_local', locals(), True)
- [Django]-Error importing external library within Django template tag library
- [Django]-Error with pip install MySQL-python
- [Django]-Django: Filter objects by date range