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_CLASSES
, e.g.:
INSTALLED_APPS = (
# ...
'waffle',
# ...
)
MIDDLEWARE_CLASSES = (
# ...
'waffle.middleware.WaffleMiddleware',
# ...
)
Jinja Templates¶
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.