django-vote
is a simple Django app to conduct vote for django model.
This project is inspired by django-taggit
pip install django-vote
INSTALLED_APPS = (
...
'vote',
)
from vote.models import VoteModel
class ArticleReview(VoteModel, models.Model):
...
manage.py makemigrations
manage.py migrate
review = ArticleReview.objects.get(pk=1)
# Up vote to the object
review.votes.up(user_id)
# Down vote to the object
review.votes.down(user_id)
# Removes a vote from the object
review.votes.delete(user_id)
# Check if the user already voted the object
review.votes.exists(user_id)
# Returns the number of votes for the object
review.votes.count()
# Returns a list of users who voted and their voting date
review.votes.user_ids()
# Returns all instances voted by user
Review.votes.all(user_id)
django-vote
now requires Django 1.7 or greater. (for Django < 1.7, please install previous release django-vote==1.1.3
)