Changes between Version 13 and Version 14 of SplitSettings


Ignore:
Timestamp:
Oct 1, 2010, 11:04:53 PM (14 years ago)
Author:
Antti Kaihola
Comment:

Added a refined method for importing local settings

Legend:

Unmodified
Added
Removed
Modified
  • SplitSettings

    v13 v14  
    308308== Accessing and modifying existing settings ==
    309309
    310 I ([http://djangopeople.net/akaihola Antti Kaihola]) have used the following solution to modify settings which are tuples or lists. This is handy e.g. when separating app-specific settings to their own files.
     310I ([http://djangopeople.net/akaihola Antti Kaihola]) use the following solution for defining local settings. It provides access to the original settings while defining local settings. Note: this only works if you import from the base {{{settings.py}}} or {{{settings/__init__.py}}}.
     311
     312settings/__init__.py:
     313{{{
     314INSTALLED_APPS = ('whatever',)
     315try:
     316    from settings.local import *
     317except ImportError:
     318    pass
     319}}}
     320
     321settings/local.py:
     322{{{
     323import sys
     324globals().update(vars(sys.modules['settings']))
     325
     326INSTALLED_APPS += ('another_app',)
     327}}}
     328
     329Older, clumsier methods I've used:
    311330
    312331settings.py:
Back to Top