Question
Is my approach to multiple Django settings files below reasonable (transparent, secure, etc.)?
My approach
I have settings.pyand a settings_local.py. settings.pyis under version control, but settings_local.pyNOT under version control. In the end, settings.pyhe tries to import settings_local.py, if available.
My theory for this approach is that I can leave my default / safe settings in settings.pyand just click on production to deploy. During the deployment settings_local.pywill not be present, and its local settings will not be used. However, when working, it is locally settings_local.pypresent and its local settings are used.
settings.py
DEBUG = False
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
)
try:
from settings_local import *
except ImportError:
pass
settings_local.py
from settings import *
DEBUG = True
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
, . , , , , .
settings_local.py import settings.py , DRY-, . MIDDLEWARE_CLASSES .
!
, . , , .
, , , , , - , @DrTyrsa @Mark Lavin, !