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