Metadata-Version: 2.1
Name: django-vote
Version: 2.2.0
Summary: A simple Django app to conduct vote.
Home-page: https://github.com/shellfly/django-vote
Author: shellfly
Author-email: shell0fly@gmail.com
License: BSD License
Description: ## Django Vote
        
        ``django-vote`` is a simple Django app to conduct vote for django model.
        
        This project is inspired by [django-taggit](https://github.com/alex/django-taggit)
        
        [![Build Status](https://travis-ci.org/shellfly/django-vote.svg?branch=master)](https://travis-ci.org/shellfly/django-vote)
        [![codecov](https://codecov.io/gh/shellfly/django-vote/branch/master/graph/badge.svg)](https://codecov.io/gh/shellfly/django-vote)
        [![PyPI version](https://badge.fury.io/py/django-vote.svg)](https://badge.fury.io/py/django-vote)
        
        ### Quick start
        
        #### Install `django-vote` by pip
        
        ```shell
        pip install django-vote
        ```
        
        #### Add `'vote'` to your `INSTALLED_APPS` setting like this
        
        ```python
        INSTALLED_APPS = (
          ...
          'vote',
        )
        ```
        
        #### Add `VoteModel` to the model you want to vote
        
        ```python
        from vote.models import VoteModel
        
        class ArticleReview(VoteModel, models.Model):
            ...
        ```
        
        #### Run migrate
        
        ```shell
        manage.py makemigrations
        manage.py migrate
        ```
        
        
        #### Use vote API
        
        ```python
        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)
        
        ```
        
        #### Use `VoteMixin` for REST API
        
        ``` python
        class CommentViewSet(ModelViewSet, VoteMixin):
            queryset = Comment.objects.all()
            serializer_class = CommentSerializer
        ```
        
        ```sh
        POST /api/comments/{id}/vote/
        POST /api/comments/{id}/vote/ {"action":"down"}
        DELETE /api/comments/{id}/vote/
        ```
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 1.7
Classifier: Framework :: Django :: 1.8
Classifier: Framework :: Django :: 1.9
Classifier: Framework :: Django :: 1.10
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 3.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/markdown
