File: installation.rst

package info (click to toggle)
python-django-waffle 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 684 kB
  • sloc: python: 3,266; makefile: 139; sh: 39; javascript: 34
file content (112 lines) | stat: -rw-r--r-- 2,711 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.. _starting-installation:

============
Installation
============

After ensuring that the :ref:`requirements <starting-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``:

.. code-block:: shell

    $ 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.

.. _hosted on PyPI: http://pypi.python.org/pypi/django-waffle
.. _on GitHub: https://github.com/jazzband/django-waffle


.. _installation-settings:

Settings
========

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

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

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


.. _installation-settings-templates:

Jinja Templates
---------------

.. versionchanged:: 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.

.. versionchanged:: 0.11

If you're using Jinja2 templates, Waffle provides a Jinja2 extension
(``waffle.jinja.WaffleExtension``) to :ref:`use Waffle directly from
templates <templates-jinja>`. 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',
        ],
        # ...
    }


.. _installation-settings-migrations:

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``:

.. code-block:: shell

    $ django-admin.py migrate

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

.. _Django migrations: https://docs.djangoproject.com/en/dev/topics/migrations/
.. _django-jinja: https://pypi.python.org/pypi/django-jinja/
.. _jingo: http://jingo.readthedocs.org/