django-updown is a reusable Django application for youtube like up and down voting.
Project description
django-updown is a simple Django application for adding youtube like up and down voting.
Usage
Add "updown" to your INSTALLED_APPS then just add a RatingField to your model and go:
from django.db import models from updown.fields import RatingField class Video(models.Model): rating = RatingField()
You can also allow the user to change his vote:
class Video(models.Model): rating = RatingField(can_change_vote=True)
Now you can write your own view to submit ratings or use the predefinded:
from updown.views import AddRatingFromModel
urlpatterns = patterns("",
url(r"^(?P<object_id>\d+)/rate/(?P<score>[\d\-]+)$", AddRatingFromModel(), {
'app_label': 'video',
'model': 'Video',
'field_name': 'rating',
}, name="video_rating"),
)
To submit a vote just go to video/<id>/rate/(1|-1). If you allowed users to change they’re vote, they can do it with the same url.
Thanks
Thanks a lot to django-ratings for the inspiring code
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-updown-0.0.3.tar.gz
(6.3 kB
view details)
File details
Details for the file django-updown-0.0.3.tar.gz.
File metadata
- Download URL: django-updown-0.0.3.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb6e7537ab16df7785e49b9f1f20353bb3ac996414b94bc901146c519c6b259c
|
|
| MD5 |
af4a5dea657b8e4dd7d7a61bd867c0c6
|
|
| BLAKE2b-256 |
abac0ca98d295a4e4f4d42efc0ef470e342fd737d74d1359990490734e55c55b
|