Installation

After ensuring that the requirements are met, installing Waffle is a simple process.

Getting Waffle

Waffle is hosted on PyPI and can be installed with pip or easy_install:

$ pip install django-waffle
$ easy_install django-waffle

Waffle is also available on GitHub. In general, master should be stable, but use caution depending on unreleased versions.

Settings

Add waffle to the INSTALLED_APPS setting, and waffle.middleware.WaffleMiddleware to MIDDLEWARE, e.g.:

INSTALLED_APPS = (
    # ...
    'waffle',
    # ...
)

MIDDLEWARE = (
    # ...
    'waffle.middleware.WaffleMiddleware',
    # ...
)

Jinja Templates

Changed in version 0.19.

If you are using Jinja2 templates, the django-jinja dependency is currently unavailable with django 3.0 and greater; 2.x versions are compatible as well as 1.11.

Changed in version 0.11.

If you’re using Jinja2 templates, Waffle provides a Jinja2 extension (waffle.jinja.WaffleExtension) to use Waffle directly from templates. How you install this depends on which adapter you’re using.

With django-jinja, add the extension to the extensions list:

TEMPLATES = [
    {
        'BACKEND': 'django_jinja.backend.Jinja2',
        'OPTIONS': {
            'extensions': [
                # ...
                'waffle.jinja.WaffleExtension',
            ],
            # ...
        },
        # ...
    },
    # ...
]

With jingo, add it to the JINJA_CONFIG['extensions'] list:

JINJA_CONFIG = {
    'extensions': [
        # ...
        'waffle.jinja.WaffleExtension',
    ],
    # ...
}

Database Schema

Waffle includes Django migrations for creating the correct database schema. If using Django >= 1.7, simply run the migrate management command after adding Waffle to INSTALLED_APPS:

$ django-admin.py migrate

If you’re using a version of Django without migrations, you can run syncdb to create the Waffle tables.