Skip to content

Instantly share code, notes, and snippets.

@gnrfan
Created June 13, 2012 16:39
Show Gist options
  • Select an option

  • Save gnrfan/2925183 to your computer and use it in GitHub Desktop.

Select an option

Save gnrfan/2925183 to your computer and use it in GitHub Desktop.
App-level configuration in Django
## app1/constants.py
MY_VAR = 100
## app1/settings.py
from django.conf import settings
from app1 import constants
MY_VAR = getattr(settings, 'MY_VAR', constants.MY_VAR)
## app1/views.py
from django.conf import settings
from app1 import settings as app1_settings
print app1_settings.MY_VAR
## project/settings/__init__.py
# MY_VAR = 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment