|
|
|
|
|
by amirkdv
1678 days ago
|
|
Having experimented with a bunch of different ways to organize complex django settings, I think what OP suggests is a local optimum that's hard to scale and doesn't solve a bunch of important problems (eg ok, credentials are now in local.py which is not committed to git. Now how do I get it to people's dev machines / CI?) 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 typos |
|