From ed6b03a7b00c3c51e71d9103eb0cf4692922bda3 Mon Sep 17 00:00:00 2001 From: Jiri Barton Date: Wed, 25 Aug 2010 11:24:40 +0200 Subject: [PATCH] updated README --- README.rst | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/README.rst b/README.rst index b3e361b..833dcbe 100644 --- a/README.rst +++ b/README.rst @@ -13,43 +13,42 @@ Install from here using ``pip``:: pip install -e hg+http://bitbucket.org/comoga/django-constance#egg=django-constance -1. Add ``constance`` to your ``INSTALLED_APPS``. +Configuration +============= -2. Point ``CONSTANCE_CONNECTION`` in your ``settings.py`` to your Redis instance, like this:: +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:: - CONSTANCE_CONNECTION = { - 'host': 'localhost', - 'port': 6379, - 'db': 0, - } -3. Create an empty section ``CONSTANCE_CONFIG`` in your settings which will - enumerate all your dynamic settings for the admin:: + INSTALLED_APPS = ( + ... + 'constance', + ) - CONSTANCE_CONFIG = { - } + CONSTANCE_CONNECTION = { + 'host': 'localhost', + 'port': 6379, + 'db': 0, + } -Usage -===== - -Add - -:: - - from constance import config - -to the top of your source and replace ``settings.MY_SETTINGS_KEY`` with -``config.MY_SETTINGS_KEY`` for each key which you want to be read -from Redis. - -Next, move each such key within your ``settings.py`` to the ``CONSTANCE_CONFIG`` -section. Keep the default value and add an explanation for the admin, like -this:: CONSTANCE_CONFIG = { 'MY_SETTINGS_KEY': (42, 'the answer to everything'), } +Usage +===== + +:: + + from constance import config + + ... + + if config.MY_SETTINGS_KEY == 42: + answer_the_question() + Fire up your ``admin`` and you should see a new application ``Constance`` with ``MY_SETTINGS_KEY`` in the ``Config`` pseudo model.