A simple Django app to conduct vote.
Project 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/shanbay/django-vote.svg?branch=develop)](https://travis-ci.org/shanbay/django-vote)
[![Codecov](https://codecov.io/gh/shanbay/django-vote/coverage.svg?branch=master)](https://codecov.io/gh/shanbay/django-vote?branch=master)
[![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)
```
``django-vote`` now requires Django 1.7 or greater. (for Django < 1.7, please install previous release `django-vote==1.1.3`)
``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/shanbay/django-vote.svg?branch=develop)](https://travis-ci.org/shanbay/django-vote)
[![Codecov](https://codecov.io/gh/shanbay/django-vote/coverage.svg?branch=master)](https://codecov.io/gh/shanbay/django-vote?branch=master)
[![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)
```
``django-vote`` now requires Django 1.7 or greater. (for Django < 1.7, please install previous release `django-vote==1.1.3`)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-vote-2.1.7.tar.gz
(195.3 kB
view details)
File details
Details for the file django-vote-2.1.7.tar.gz
.
File metadata
- Download URL: django-vote-2.1.7.tar.gz
- Upload date:
- Size: 195.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44cee16a9a55da1a57524cad18f95f0b58317c6c7d9eb2676f56d47384d809a2 |
|
MD5 | 82160ec2943095d6aad7774add51908b |
|
BLAKE2b-256 | 4349cf421c04052c036fb4e2fa00006ef6403a1cd34df023fa8e0712b21e3497 |