I am working on a Django project that uses dozens of configuration variables specified in several configuration files located in the root directory of the project:
--> myproject ------> app folders ------> ... --- settings.py --- settings_global.py --- settings_production.py --- settings_development.py
Then the variables from different settings_ * files are imported into the settings.py file based on certain run-time parameters (host name, etc.). All this works pretty well, but sometimes itβs still hard to find a specific variable, so I would like to reinstall the parameter variables and divide them into several categories:
- project-specific variables
- django dependent variables
- specific variables of the installed application (such as settings for django_compressor, etc.)
- environment variables (production / development)
Also I would like to move all the settings files, but settings.py to the settings folder:
--> myproject ------> app folders ------> ... ------> settings ---------- __init__.py ---------- common.py ---------- production.py ---------- development.py ---------- apps.py ---------- ... --- settings.py
I created a settings subdirectory (as well as an empty __init__.py file) and copied / renamed the settings files. Then I tried to import these variables into settings.py file as follows:
from settings.common import * from settings.apps import *
However, I get the following error (although ROOT_URLCONF exists in the settings / common.py file):
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'
What am I doing wrong?
MikeAr
source share