2010-08-25 08:30:58 +00:00
|
|
|
Dynamic Django settings in Redis.
|
|
|
|
|
|
|
|
|
|
Features
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
* Easy migrate your static settings to dynamic settings.
|
|
|
|
|
* Admin interface to edit the dynamic settings.
|
|
|
|
|
|
|
|
|
|
Installation
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
Install from here using ``pip``::
|
|
|
|
|
|
|
|
|
|
pip install -e hg+http://bitbucket.org/comoga/django-constance#egg=django-constance
|
|
|
|
|
|
2010-08-25 09:24:40 +00:00
|
|
|
Configuration
|
|
|
|
|
=============
|
2010-08-25 08:30:58 +00:00
|
|
|
|
2010-08-25 09:24:40 +00:00
|
|
|
Modify your ``settings.py``. Add ``constance`` to your ``INSTALLED_APPS``,
|
|
|
|
|
point ``CONSTANCE_CONNECTION`` to your Redis instance, and move each
|
|
|
|
|
key you want to turn dynamic into the ``CONSTANCE_CONFIG`` section, like this::
|
2010-08-25 08:30:58 +00:00
|
|
|
|
|
|
|
|
|
2010-08-25 09:24:40 +00:00
|
|
|
INSTALLED_APPS = (
|
|
|
|
|
...
|
|
|
|
|
'constance',
|
|
|
|
|
)
|
2010-08-25 08:30:58 +00:00
|
|
|
|
2010-08-25 09:24:40 +00:00
|
|
|
CONSTANCE_CONNECTION = {
|
|
|
|
|
'host': 'localhost',
|
|
|
|
|
'port': 6379,
|
|
|
|
|
'db': 0,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CONSTANCE_CONFIG = {
|
|
|
|
|
'MY_SETTINGS_KEY': (42, 'the answer to everything'),
|
|
|
|
|
}
|
2010-08-25 08:30:58 +00:00
|
|
|
|
|
|
|
|
Usage
|
|
|
|
|
=====
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
from constance import config
|
|
|
|
|
|
2010-08-25 09:24:40 +00:00
|
|
|
...
|
2010-08-25 08:30:58 +00:00
|
|
|
|
2010-08-25 09:24:40 +00:00
|
|
|
if config.MY_SETTINGS_KEY == 42:
|
|
|
|
|
answer_the_question()
|
2010-08-25 08:30:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Fire up your ``admin`` and you should see a new application ``Constance``
|
|
|
|
|
with ``MY_SETTINGS_KEY`` in the ``Config`` pseudo model.
|
|
|
|
|
|