July 2019
Beginner to intermediate
302 pages
9h 38m
English
We can have a default setting base class, and other classes can inherit that base class and override or add deployment-specific configuration variables to it, as shown in the following example:
class BaseConfig(object):
'Base config class'
SECRET_KEY = 'A random secret key'
DEBUG = True
TESTING = False
NEW_CONFIG_VARIABLE = 'my value'
class ProductionConfig(BaseConfig):
'Production specific config'
DEBUG = False
SECRET_KEY = open('/path/to/secret/file').read()
class StagingConfig(BaseConfig):
'Staging specific config'
DEBUG = True
class DevelopmentConfig(BaseConfig):
'Development environment specific config'
DEBUG = True
TESTING = True
SECRET_KEY = 'Another random secret key'