While Django encourages a healthy degree of decoupling in how apps and modules are structured, the settings file can very easily become a monolithic mess. There are some good resources for how to divide up settings file between environments, but with a big application, even that can leave you with a mess of configuration settings.

What is particularly annoying in this situation is that many of these settings really just affect one app. For example, I store JavaScript and CSS files specific to each app in app_dir/static/ and then use django-pipeline to wrap and compress all the files for deployment. However, Django Pipeline requires you to define Groups in your settings.py file. However, since those groups are specific to each app, it seems like they should live with the app, not in the settings file. Adding a css file shouldn’t require me to change the settings.

At first I attempted to fix this by putting a settings.py file in each app’s directory, but Django doesn’t automatically import those files and attempting to do so manually in Django’s own settings files lead to all sorts of messy import loops. However, I found a much simpler solution. Simply put the extra settings in the __init__.py file in the app root. This get’s imported automatically when the app is installed and those settings will automatically be added to the general settings environment.