| | 264 | |
| | 265 | == Using a list of conf files (Transifex) == |
| | 266 | |
| | 267 | [http://transifex.org/ Transifex] has adopted a solution using an ordered list of multiple `.conf` files inside a settings directory. This helps separating the config options, packaging in Linux distributions, and putting the settings files under `/etc`. |
| | 268 | |
| | 269 | {{{ |
| | 270 | $ ls settings/ |
| | 271 | |
| | 272 | 10-base.conf |
| | 273 | 20-engines.conf |
| | 274 | 30-site.conf |
| | 275 | ... |
| | 276 | |
| | 277 | $ cat settings.py |
| | 278 | |
| | 279 | import os.path |
| | 280 | import glob |
| | 281 | conffiles = glob.glob(os.path.join(os.path.dirname(__file__), 'settings', '*.conf')) |
| | 282 | conffiles.sort() |
| | 283 | for f in conffiles: |
| | 284 | execfile(os.path.abspath(f)) |
| | 285 | }}} |
| | 286 | |
| | 287 | To apply local-only changes, create a `XX-local.conf file`, which can be ignored with your VCS of choice: |
| | 288 | |
| | 289 | {{{ |
| | 290 | $ cat settings/51-local.conf |
| | 291 | |
| | 292 | INSTALLED_APPS += ['debug_toolbar'] |
| | 293 | |
| | 294 | $ cat .hgignore |
| | 295 | |
| | 296 | syntax: glob |
| | 297 | settings/*-local.conf |
| | 298 | }}} |