== What is Tupperware? ==

Tupperware lets you move settings out of the file and into the database. It allows you to have different settings for each site and automatically updates your settings object for each request.

== How to install ==

  1. Make sure you have the dependencies

  2. Put the "tupperware" directory somewhere in your python path

    OR at the command line, run: $ python install

  3. Add tupperware to your installed apps (in the file)


    ... other django apps...



  4. Add tupperware to the beginning of your MIDDLEWARE_CLASSES setting (

    MIDDLEWARE_CLASSES = ( 'tupperware.middleware.SiteSettings', ... other middleware...


  5. It is highly reccommended that you use caching (otherwise you'll be

    hitting the database for all your settings on every request). If you're using a cache you need to use the tupperware cache wrapper.

    In your

    # Your cache backend of choice (used to be the CACHE_BACKEND setting) CUSTOM_CACHE_BACKEND = 'file:///tmp/djangocache'

    # The tupperware cache wrapper CACHE_BACKEND = 'tupperware.cache_wrapper://'

  6. create the necessary tables in the database. At the command line:

    $ python syncdb

== Gotchas ==

Be careful of overwriting the database settings. The settings are loaded from the database. It probably won't work.

There are a few settings that you can't overwrite, mostly pertaining to the current site.

  • special cases -

    settings.SITE_ID - (read only) don't try to override this setting. it

    is loaded from

    settings.SITE_NAME - loaded from (and written to)

    settings.DEFAULT_FROM_EMAIL - (read only) returns noreply@{{ site.domain }}

    you can remove the getter from tupperware.managers to make it act like a normal setting

    settings.CONTACT_EMAIL - (read only) returns feedback@{{ site.domain }}

    you can remove the getter from tupperware.managers to make it act like a normal setting

== Using Settings from Tupperware ==

Tupperware monkey-patches django's settings object. Just keep using django settings like you always did.

from django.conf import settings

# This value is pulled from database. If it is not found, it uses the # file like normal.


== Changing settings on the fly ==

Tupperware adds an "update" method to the settings object. It works just like the "update" method you see on python's built in dict object.

from django.conf import settings

# changes the value of settings.SOME_SETTING (stores it in the database) # the setting will be changed for the current site only. settings.update({



To change settings for a different site than the current site:

from django.contrib.sites.models import Site from tupperware.models import SiteSetting

site = Site.objects.get(id=site_id) SiteSetting.objects.update({


}, site=site)