I am trying to tidy up my configuration file, and I wanted to split it into several files that can be edited based on the deployment need.
So in my project directy I have a subdirectory called config containing a few specific configuration files
My “main” configuration file (settings.py) is located in my project directory (where models.py and manage.py are). Sub-configuration files are in the “config” directory:
ProjectName
+ config
- common.py
- specific.py
- settings.py
This is what the settings.py file looks like:
appPath = "path/to/my/app"
configPath = "path/to/my/app/config"
folders = [os.path.dirname(appPath), os.path.dirname(configPath)]
for f in folders:
if f not in sys.path:
sys.path.insert(0, f)
from MyApp.config import common
from MyApp.config import specific
However, this does not seem to set any of the settings I am using in the common.py and specific.py files.
I also tried the following:
from MyApp.config import common as django_settings
and
from MyApp.config.common import *
None of these seem to work.
I have the __init__.py in my config directory
Thanks,
You should be able to do
You shouldn’t have to mess with the Python path, either, as Django’s
manage.pyscript will add the its directory and its parent to the path.