7

I am working on Django project that uses several dozen configuration variables specified in several "settings" files located in project's root directory:

--> myproject
------> app folders
------> ...
--- settings.py
--- settings_global.py
--- settings_production.py
--- settings_development.py

Variables from different settings_* files are then get imported in settings.py file based on certain run-time parameters (host name etc). It all works rather well, but sometimes it's still hard to locate certain variable, so I'd like re-organize settings variables and split them into several categories:

  • project-specific variables
  • django-specific variables
  • installed-app specific variables (such as settings for django_compressor, etc)
  • environment-specific variables (production/development)

Also I'd like to move all settings files but settings.py file to settings subdirectory:

--> myproject
------> app folders
------> ...
------> settings
---------- __init__.py
---------- common.py
---------- production.py
---------- development.py
---------- apps.py
---------- ...
--- settings.py

I've created settings subdirectory (as well as empty __init__.py file) and copied/renamed the settings files. Then I tried to import those variables in my setting.py file as following:

from settings.common import *
from settings.apps import *

However, I am getting the following error (even though ROOT_URLCONF exists in settings/common.py file):

AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'

What am I doing wrong?

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
MikeAr
  • 1,011
  • 8
  • 9
  • I get this in apache error log (after restarting the process and visiting the project's page) – MikeAr Apr 10 '12 at 07:15
  • Related: http://stackoverflow.com/questions/2035733/how-to-modularize-django-settings-py http://stackoverflow.com/questions/5583077/django-settings-py-separate-local-and-global-configuration http://stackoverflow.com/questions/1626326/how-to-manage-local-vs-production-settings-in-django – dani herrera Apr 10 '12 at 07:25

1 Answers1

7

I think there's a name collision between your settings.py module and the settings package, try renaming the package to something else

Claude Vedovini
  • 2,421
  • 21
  • 19