Yes, definitely. The settings.py file is just Python, so you can do anything you like, including dynamically adjusting and import other files for redefinition.
So, there are two approaches. The first is not to hard-code any paths, but to compute them dynamically.
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) TEMPLATE_DIRS = [ os.path.join(PROJECT_ROOT, "templates"), ]
etc .. The Python magic keyword __file__ indicates the path to the current file.
The second is the presence of the local_settings.py file outside SVN, which is imported at the end of the main settings.py parameters and overrides any settings there:
try: from local_settings import * except ImportError: pass
Try / except is that it works even if local_settings does not exist.
Naturally, you could try a combination of these approaches.
Daniel Roseman
source share