• Stars
    star
    124
  • Rank 288,133 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A reusable Django app that lets users write reviews for any model

Django Review

A reusable Django app that lets users write reviews for any model

Installation

To get the latest stable release from PyPi

$ pip install django-review

To get the latest commit from GitHub

$ pip install -e git+git://github.com/bitmazk/django-review.git#egg=review

TODO: Describe further installation steps (edit / remove the examples below):

Add review to your INSTALLED_APPS

INSTALLED_APPS = (
    ...,
    'hvad',
    'review',
    'user_media',
    'generic_positions',
)

Add the review URLs to your urls.py

urlpatterns = patterns('',
    ...
    url(r'^review/', include('review.urls')),
)

Don't forget to migrate your database

./manage.py migrate

Usage

The only step you'll have to take is to link to the review views. For example, you created a Book model, which should be reviewed by users.

Create a button and add some markup like:

<a href="{% url "review_create" content_type='book' object_id=book.pk %}">{% trans "Review this book" %}</a>

Ratings & Categories

To make use of ratings you'll have to create RatingCategory objects. For example, you want to allow reviews of a hotel booking. You now might add categories like "room", "service", "food" or whatever. After you have created those categories in the standard Django admin interface they will appear in your review form. The average rating of an object is generated by all of its category ratings.

Template tags

total_review_average

For rendering the total review average for any object, you can use the assignment tag total_review_average. It automatically calculates the averages of all reviews for the given object and you can specify what range it should have. The following examples would resemble a percentage or a stars rating:

{% load review_tags %}
{% total_review_average object 100 as percentage %}
<p>{{ percentage }}% of our users recommended this!</p>

{% total_review_average object 5 as stars %}
<p>This object got {{ stars }} out of 5 stars.</p>

render_category_averages

Renders the template review/partials/category_averages.html to display a table of categories with their average rating. Again, you can specify what maximum rating value the averages normalize to.

{% load review_tags %}
{% render_category_averages object 100 %}

If you had 2 categories, this would per default render to something like the following example, but you can of course customize the template to your needs.

<table>
    <tr><th>Category 1:</th><td>10.0</td></tr>
    <tr><th>Category 2:</th><td>20.0</td></tr>
    <tr><th>Amount of reviews:</th><td>2</td></tr>
</table>

get_reviews

An assignment tag, that simply returns the reviews made for the given object. An example usage would look like this:

{% load review_tags %}

{% get_reviews object as reviews %}
{% for review in reviews %}
    <p>
        {{ review.get_average_rating }}
    </p>
    <p>
        {% if review.content %}
            {{ review.content|truncatewords:'70' }}
        {% else %}
            Reviewed without description.
        {% endif %}
    </div>
    <a href="{% url "review_detail" pk=object.pk %}">Review details</a>
{% endfor %}

get_review_average

An assignment tag, that returns the review average for the given object. An example usage would look like this:

{% load review_tags %}

{% get_review_average object as review_average %}
<p>This object is rated by {{ review_average }}</p>

get_review_count

An assignment tag, that simply returns the amount of reviews made for the given object. An example usage would look like this:

{% load review_tags %}

{% get_review_count object as review_count %}
<p>{{ review_count }} users have reviewed this so far.</p>

user_has_reviewed

To quickly check if a user has already reviewed the given object, you can use this template tag. An example usage could be something like this:

{% load review_tags %}
{% user_has_reviewed myobject request.user as has_reviewed %}
{% if has_reviewed %}
    <p>Thanks for your opinion!</p>
{% else %}
    <a href="{% url "review_create" content_type='book' object_id=book.pk %}">{% trans "Review this book" %}</a>
{% endif %}

Settings

Default behaviour:

  • Users can rate form 0 to 5
  • Only authenticated users can post a review
  • Users can post multiple reviews on one object
  • Users can always update their posted reviews

If you want to change this behaviour, or if you like to add some more permission checks, read on.

REVIEW_RATING_CHOICES

If you want other rating choices than 0-5, you can define a new tuple, like:

REVIEW_RATING_CHOICES = (
    ('1', 'bad'),
    ('2', 'average'),
    ('3', 'excellent'),
)

REVIEW_ALLOW_ANONYMOUS

Allows anonymous review postings, if set to True.

REVIEW_DELETION_SUCCESS_URL

Name of the URL to redirect to after deleting a review instance. This could be your review listing, for example.

REVIEW_UPDATE_SUCCESS_URL (optional)

Default: DetailView of the instance.

Name of the URL to redirect to after creating/updating a review instance. This could be your review listing, for example.

REVIEW_UPDATE_SUCCESS_URL = 'my_view_name'

Or you can also specify a function, that returns the full path. The function then takes the review as parameter, so you can also access the reviewed item like follows

REVIEW_UPDATE_SUCCESS_URL = lambda review: review.reviewed_item.get_absolute_url()

REVIEW_AVOID_MULTIPLE_REVIEWS

Avoids multiple reviews by one user, if set to True. Doesn't work with anonymous users.

REVIEW_PERMISSION_FUNCTION

Custom function to check the user's permission. Use a function and note that the user and the reviewed item are only parameters.

REVIEW_PERMISSION_FUNCTION = lambda u, item: u.get_profile().has_permission(item)

REVIEW_UPDATE_PERIOD

You can limit the period, in which a user is able to update old reviews. Make sure to use minutes, e.g. 2880 for 48 hours.

REVIEW_CUSTOM_FORM

You can create your own review form (e.g. if you want to make use of the review extra info). Just name it.

REVIEW_CUSTOM_FORM = 'myapp.forms.MyCustomReviewForm'

Take a look at the included test app to get an example.

You can also use a custom form to add another content object to the review instance.

REVIEW_FORM_CHOICE_WIDGET

If you only want to override Django's default widget for the used ChoiceField, that is used in the form, you can specify this optional setting.

# this would use a RadioSelect instead of the default Select
REVIEW_FORM_CHOICE_WIDGET = 'django.forms.widgets.RadioSelect'

Contribute

If you want to contribute to this project, please perform the following steps

# Fork this repository
# Clone your fork
$ mkvirtualenv -p python2.7 django-review
$ python setup.py install
$ pip install -r dev_requirements.txt

$ git co -b feature_branch master
# Implement your feature and tests
$ git add . && git commit
$ git push -u origin feature_branch
# Send us a pull request for your feature branch

More Repositories

1

django-calendarium

A reusable Django app to manage and display a calendar in your templates.
Python
219
star
2

django-booking

A reusable Django app that manages bookings for various purposes.
Python
209
star
3

django-libs

Commonly used building blocks for Django projects and apps.
Python
96
star
4

django-reusable-app-template

A template for kickstarting reusable Django apps, ready to be published on pypi.python.org, ready for test driven development.
Python
95
star
5

django-influxdb-metrics

A reusable Django app that sends metrics about your project to InfluxDB
Python
84
star
6

django-registration-email

*DISCONTINUED* A custom registration and authorization backend that allows user signup via email.
Python
52
star
7

django-metrics-dashboard

A reusable Django app for displaying a dashboard with a fluid grid of widgets.
Python
44
star
8

django-reusable-app-boilerplate

A skeleton for a reusable Django app, ready for test driven development.
Python
41
star
9

django-user-media

File uploads for your users.
Python
38
star
10

ansible-digitalocean-influxdb-grafana

Ansible playbook to install influxdb and grafana on a DigitalOcean Ubuntu 14.04 droplet.
JavaScript
37
star
11

django-paypal-express-checkout

A reusable Django app to include a PayPal payment flow to your site.
Python
36
star
12

blogpost-react-websocket-chat

Companion repository for a blog post about chat, react and websocket
JavaScript
28
star
13

django-payslip

A reusable Django app for managing salary information and printing nice payslips for each employee.
Python
28
star
14

django-dashboard-app

A reusable Django app for displaying a dashboard with a fluid grid of widgets.
Python
27
star
15

django-conversation

A reusable Django app that provides threaded conversations between users.
Python
26
star
16

django-tinylinks

Yet another URL shortener
Python
25
star
17

cmsplugin-image-gallery

A plugin for Django-CMS to display galleries, based on django-filer folders.
Python
22
star
18

django-object-events

Generic app for creating events that can be shown to the user in a notifications list.
Python
22
star
19

django-project-template

A template for kickstarting new Django projects.
HTML
20
star
20

django-event-rsvp

A reusable Django app to create event pages where users can RSVP.
Python
19
star
21

django-forms-ajaxified

A reusable Django app that allows to load and submit forms via AJAX.
Python
19
star
22

django-generic-positions

This is a generic app for using a drag & drop position field, wherever you want to.
Python
18
star
23

django-multilingual-news

A reusable Django app for managing news/blog entries in different languages.
Python
18
star
24

django-development-fabfile

A fabfile to ease many tasks during development and deployment of Django projects.
Python
17
star
25

django-people

An app for showing person profiles, for example for your "About us" section.
Python
17
star
26

webfaction-django-boilerplate

*DISCONTINUED* Setup your new Webfaction server in a matter of minutes
Python
16
star
27

webfaction-django1.4-boilerplate

*DISCONTINUED*
Python
15
star
28

ansible-ubuntu-django

Ansible playbook to provision an Ubuntu server with Django, nginx, uwsgi, supervisor, PostgreSQL
Nginx
15
star
29

django-frequently

Yet another FAQ app.
Python
14
star
30

django-user-tags

A tagging app for Django where tags are separated on a per-user basis
Python
14
star
31

webfaction-dotfiles

Some settings I like to have on all my Webfaction servers
Vim Script
13
star
32

django-account-keeping

A reusable Django app for keeping track of transactions in your bank accounts.
Python
13
star
33

django-shop-simplenotifications

*DISCONTINUED* A simple reusable app for django-shop that sends email notifications on certain events.
Python
13
star
34

django-feedback-form

Minified JQuery & Ajax feedback form to handle fast customer requests in Django
Python
12
star
35

django-subscribe

A simple subscription app for Django.
Python
11
star
36

bitmazk-environment

Tools and libraries needed for web development at bitmazk
Shell
11
star
37

django-document-library

A multilingual document library based on django-filer
Python
10
star
38

django-newsletter-signup

Python
10
star
39

django-online-docs

Display user documentation for the view that is currently displayed.
Python
10
star
40

bitmazk-contact-form

A reusable contact form application for Django and django-cms
Python
9
star
41

cmsplugin-markdown

A plugin for django-cms for adding content to your placeholders via Markdown with the awesome EpicEditor
JavaScript
9
star
42

ansible-webfaction-gunicorn-django

*DISCONTINUED* Ansible playbook for setting up a Webfaction server for advanced Django projects
Nginx
9
star
43

django-unshorten

A reusable Django app for un-shortening URLs
Python
9
star
44

django-honeypot-signals

*DISCONTINUED* signal handlers for django-admin-honeypot for email notifications when you get hacked.
Python
8
star
45

bitmazk-book

Fork our company!
Python
8
star
46

django-hero-slider

Django app to define images to be shown on a frontpage slider. They can link to any object.
Python
8
star
47

django-socketio-messenger

*DISCONTINUED* A small Django project that acts as a proxy for your socket.io magic...
Python
7
star
48

django-rapid-prototyping

A reusable Django app that helps to create prototypes and cost estimations.
Python
7
star
49

django-monitoring

A reusable Django app to monitor all aspects of your webapp
Python
7
star
50

django-command-interface

Python
7
star
51

django-docker-aws

Python
7
star
52

jquery-typeahead-tagging

A jQuery plugin to turn a regular input into a tag input with typeahead autocompletion.
JavaScript
6
star
53

django-media-library

Python
6
star
54

django-brutebuster-signals

*DISCONTINUED* post_save signal handlers for Django BruteBuster for email notifications when you get hacked.
Python
6
star
55

django-currency-history

Reusable app to track currency courses
Python
6
star
56

django-privacy

Reusable Django app to add privacy settings to fields and/or objects
Python
6
star
57

pyplaintext

A HTML to plaintext converter.
Python
6
star
58

django-crowdsourced-fields

Reusable django app that allows to turn some fields of your models into special fields with jQuery comboboxes.
Python
5
star
59

flake8-snippets

A flake8 extension to find any code snippets you don't like
Python
5
star
60

django-flipbook

A reusable Django app that displays a gallery in a flipbook format.
Python
5
star
61

cmsplugin_blog_paginated

*DISCONTINUED* Overrides the index view of cmsplugin_blog's urls.py in order to provide pagination for that view.
Python
5
star
62

django-roadmap

A simple app to display a project roadmap with milestones and events.
Python
5
star
63

django-multilingual-survey

Survey app that allows questions and answers to be created in several languages.
Python
5
star
64

django-multilingual-tags

A reusable Django app that allows you to add translatable tags to any other model.
Python
5
star
65

django-page-rating

Ask your users "Was this content helpful?" And monitor upvotes and downvotes per URL
Python
4
star
66

django-localized-names

Python
4
star
67

django-dumpdata-field

Custom dumpdata and loaddata commands that allow to export/import a certain field of a model
Python
4
star
68

django-social-media-links

*DISCONTINUED* A reusable Django app that renders a set of social media links, i.e. for your website footer.
Python
4
star
69

django-ics-generator

Django app to return a .ics file when called via http://www.keith-wood.name/icalendar.html
Python
3
star
70

django-task-list

A reusable Django app to attach task lists to models and let them be managed by multiple users.
Python
3
star
71

django-enquiry

A simple poll application.
Python
3
star
72

cmsplugin-googlemap

Python
3
star
73

django-oscar-asiapay

AsiaPay integration for django-oscar.
Python
3
star
74

django-dynamic-content

A reusable Django app that allows to place dynamic content into templates.
Python
2
star
75

python-server-metrics

A very simple set of methods to collect metrics about your servers
Python
2
star
76

django-ad-rotator

Python
2
star
77

pypispy-github-test

Repository for the test cases of the pypispy-agent application
Python
2
star
78

django-good-practice-examples

Python
2
star
79

cmsplugin-template-placeholder

A django-cms plugin with a better placeholder tag.
Python
2
star
80

pypispy-pypi-test

Repository for the pypi.python.org related test cases of the pypispy-agent application
1
star
81

md-urlunshorten-users

A django-metrics-dashboard widget that displays the user counts of urlunshorten.com
Python
1
star
82

django-units

Python
1
star
83

cmsplugin-video-gallery

A reusable Django app to display video plugins in placeholders or a video gallery with cms apphook.
Python
1
star
84

djangocms-text-redactor

*DISCONTINUED* A cmsplugin similar to the text plugin, just with the redactor editor
Python
1
star
85

cmsplugin-pdf

Python
1
star
86

md-playerpointer-users

django-metrics-dashboard widget to display the current user count of playerpointer.com
Python
1
star
87

mobile-project-template

Starter template for mobile apps with django-rest-framework, Cordova and ReactJS
Java
1
star
88

django-aps-project

Demo project for django-aps
Python
1
star
89

md-pypispy-users

Widget for django-metrics-dashboard that displays the number of users of pypispy.com
Python
1
star
90

django-markdown-utils

A reusable Django app with some useful markdown utilities
Python
1
star
91

django-form-serializer

A helper tool that turns Django forms into JSON dicts so that you can render them in your JS frontend.
Python
1
star
92

pypispy-agent

Server side script that sends your pip freeze result to the pypispy.com API
Python
1
star
93

cmsplugin-redirect

Python
1
star
94

python-server-metrics-scripts

A few Python scripts to report server metrics to InfluxDB
Python
1
star
95

cmsplugin-blog-categories

*DISCONTINUED* An extension for cmsplugin-blog which adds categories to the blog.
Python
1
star
96

django-multilingual-events

A simple event app to create event pages for events such as conferences.
Python
1
star
97

django-mailer-throttled

Addon for django-mailer that allows to send throttled emails
Python
1
star
98

jquery-drop-down-menu

Simple jQuery plugin for mobile friendly drop down menus
JavaScript
1
star
99

django-logger

A reusable Django app that allows you to log events and save them to your database so that you can run computations and reports on them later.
Python
1
star
100

django-traces

A reusable app to track view hits
Python
1
star