Quickstart
Install django-secretballot:
pip install django-secretballot
Add secretballot to your INSTALLED_APPS:
# settings.py
INSTALLED_APPS += [
"secretballot"
]
Activate SecretBallotIpMiddleware or SecretBallotIpUseragentMiddleware middleware class (see Tokens and SecretBallotMiddleware):
MIDDLEWARE = [
...
"secretballot.middleware.SecretBallotIpMiddleware",
# or
"secretballot.middleware.SecretBallotIpUseragentMiddleware",
]
Be sure you have django.template.context_processors.request processor listed in TEMPLATES["OPTIONS"]["context_processors"] setting:
TEMPLATES = [
{
...
"OPTIONS": {
"context_processors": [
...
"django.template.context_processors.request",
],
},
},
]
In order to attach the voting helpers to a particular model, it is enough to list them in SECRETBALLOT_FOR_MODELS setting and you’re almost done.
SECRETBALLOT_FOR_MODELS = {
"<app_label.model_name>": {},
}
Run ./manage.py migrate. This creates the tables in your database that are necessary for operation.
Please see example application on Github. This application is used to manually test the functionalities of this package. This also serves as a good example.