djes provides a few tools to help you keep your Django settings
clean and readable:
-
Settingsclass is a placeholder for you settings. Once instantiated, you can use it like a dictionary and then move its content into the local namespace of yoursettings.py. -
modecheck ifDJES_MODEenvironment variable was set. You can use it to provide different settings in a different environments.
Define settings with djes:
import djes
settings = djes.Settings()
settings['debug'] = True # you don't have to use uppercase notation
settings.install(locals())Different settings based on the DJES_MODE variable:
def production(settings):
settings['debug'] = False
def developments(settings):
settings['debug'] = True
import djes
settings = djes.Settings()
if djes.mode('prod'):
production(settings)
elif djes.mode('dev') or djes.is_local():
development(settings)
else:
raise ValueError('Invalid mode')
settings.install(locals())