The possible solutions I found accross the web:
- Always access settings by calling
getattr()
with a default value.
Pro: simple, elegant, sounds like a good practice.
Con: won't help with settings for which a default value doesn't make sense (like an API key). - Use a third party solution like django-appconf or django-appsettings.
Pro: keeps you from diving too deep into the problematic. Con: some might find it quite overwhelming. - Put the specific extra settings
__init__.py
file in the app root, like suggested in Chris Burnor's post.
Pro: clearly highlights you app's settings, makes it easy to find and to ship Con: might be a hell to deploy if you use a templating system; also might be a bit misleading since it's not such a well known practice (to my knowledge). - Introduce some logic around your settings handling, like in this snippet.
Pro: does the job.
Con: logic doesn't have anything to do there.