Changes between Version 9 and Version 10 of SplitSettings


Ignore:
Timestamp:
Jan 18, 2010, 9:08:35 AM (15 years ago)
Author:
Antti Kaihola
Comment:

added a solution for accessing and modifying existing settings

Legend:

Unmodified
Added
Removed
Modified
  • SplitSettings

    v9 v10  
    301301settings/*-local.conf
    302302}}}
     303
     304== Accessing and modifying existing settings ==
     305
     306I ([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.
     307
     308settings.py:
     309{{{
     310INSTALLED_APPS = ('whatever',)
     311import more_settings
     312more_settings.modify(globals())
     313}}}
     314
     315more_settings.py:
     316{{{
     317def modify(settings):
     318    settings['INSTALLED_APPS'] += ('another_app',)
     319}}}
     320
     321alternate more_settings.py with more magic:
     322{{{
     323def config(INSTALLED_APPS=(), **other_settings):
     324    INSTALLED_APPS += ('another_app',)
     325    return locals()
     326
     327def modify(settings):
     328    settings.update(config(**settings))
     329}}}
Back to Top