I'm starting a django 1.10 project and would like to split the settings file. I was unsatisfied with any existing solutions.
INSTALLED_APPS += (test_app)
builtins.BASE_DIR = BASE_DIR
builtins.os = os
from .common_settings import *
from . import local_settings
# At this point both modules have run and we no longer need to be messing
# with the builtins namespace.
The main problem with modifying
builtins in this way is that it adds non-local reasoning to your code for no good reason. The behavior of the common/local settings modules now implicitly depends on what happens in the module that imports them. That's bad.
Essentially, you need to get rid of your requirement #3.
os in each module isn't "repeating yourself" because each module imports
os into its own namespace. That's just how Python works.
You're right to want to only define
BASE_DIR once, but the correct way to do this is to define the variable in one module (say
basedir.py) and then explicitly import that variable (
from basedir import BASE_DIR) into each module that uses it.