by amirkdv · 5y ago · 0 comments
My key observation is this: If you're actually deploying and maintaining a django app you can't escape having quite a few environment variables that control different pieces of config. Once I accept that I can't shake these off, I'd rather minimize all other complexity, including having to reason about multiple settings modules that import/override each other in creative ways.
What I've settled on is:
1. Every thing controlled by env vars, not choice of settings module
2. the one and only settings.py toggles config based on env vars, say something like this:
STORAGE_MODE = os.environ['STORAGE_MODE']
STATICFILES_STORAGE = {
'local': '...StaticFileStorage',
's3': '...S3Boto3Storage'
}[STORAGE_MODE]
EDIT: wording and typosNo comments yet.