How to make some Django settings accessible by staff?

Something like dbsettings (as you mentioned) seems like the way to go. From the reasons for existence for that project:

Not all settings belong in settings.py, as it has some particular limitations:

  • Settings are project-wide. This not only requires apps to clutter up settings.py, but also increases the chances of naming conflicts.

  • Settings are constant throughout an instance of Django. They cannot be changed without restarting the application.

  • Settings require a programmer in order to be changed. This is true even if the setting has no functional impact on anything else.

If dbsettings doesn't work for you, then implement your own, or fork it. It doesn't seem like it'd be too arduous.


I'm actually a big fan of dbsettings, and keep meaning to publish my fork that patches it to work with Django 1.1 (not actually a big change). Looks like someone has updated it already.

However, you're probably right that this is overkill for what you need. One thing I've done before is to add a line to the end of settings.py that imports and parses a YAML file. YAML is a simple markup language, which at its most basic is just KEY: VALUE ...

CONSTANT1: MyValue
CONSTANT2: Anothervalue

If you put this somewhere editors can access it, then at the end of settings.py you just do:

import yaml
try:
    globals().update(yaml.load(open('/path/to/my/yaml/file.yml')))
except:
    pass

You'll need the Python YAML library to parse the YML file.

The downside to this approach is that you'll need to restart Apache to get it to pick up the changes.

Edited to add It wouldn't be particularly difficult to build a front end which could edit this file, and provide a button which runs a script to restart Apache.