/django-und

Django Up and Down - upvote and downvote mixin for django models

Primary LanguagePythonGNU Lesser General Public License v3.0LGPL-3.0

Django Up & Down

A django app that adds upvote and downvote to your models

Build Status codecov PyPI version

Usage

Add VoteMixin to your models.

from django.contrib.auth.models import User
from django.db import models

from django_und.models import VoteMixin

class Article(VoteMixin, models.Model):
    title = models.CharField('title', max_length=200)
    content = models.TextField('content')

Upvote and downvote :

article = Article(title="Test Article", content="Lorem Ipsum")
article.upvote(user)  # user is a instance of settings.AUTH_USER_MODEL
article.und_score  # 1
article.und_score_up  # 1
article.und_score_down  # 0
article.downvote(user)

See tests to see exhaustive usage examples.

License

Django up & down is available under the terms of LGPL-v3 license