by flashingpumpkin · 13y ago · 0 comments
STATIC_URL = os.environ.get('STATIC_URL', '/static/')
This is a lot saner and won't descend into a mess that is keeping multiple settings files around. It's also a lot easier to explain. ENVIRONMENT = os.environ.get('ENVIRONMENT', None)
if not ENVIRONMENT in ('development', 'staging', 'production'):
raise Exception('You need to set ENVIRONMENT variable')
if ENVIRONMENT == 'development':
# ...
elif ENVIRONMENT == 'staging':
# ...The environ trick is nice, and while it makes it harder to shoot yourself in the foot, it doesn't prevent it.
It is a good idea nonetheless, so you can inject the variables needed from the outside