Skip to main content

A django rating widget with a lookup-table for score-making rules.

Project description


A django rating widget with a lookup-table for score-making rules.


pip install django-lookup-table-rating-widget




  • We used jquery staic file, so we NEED add django_static_jquery3 in INSTALLED_APPS.
  • We used template of django-lookup-table-rating-widget, so we NEED add django_lookup_table_rating_widget in INSTALLED_APPS.


from django.contrib import admin
from django.utils.lorem_ipsum import sentence
from django_lookup_table_rating_widget.widgets import DjangoLookupTableRatingWidget
from django import forms
from .models import Book

s1_scores = [
        "scores": [1, 2],
        "rule": "<b>Bad</b>. " + sentence(),
        "scores": [3, 4],
        "rule": "<b>Not bad</b>. " + sentence(),
        "scores": [5, 6],
        "rule": "<b>Good</b>. " + sentence(),
        "scores": [7, 8],
        "rule": "<b>Very Good</b>." + sentence(),
        "scores": [9, 10],
        "rule": "<b>Excellent</b>." + sentence(),

class BookForm(forms.ModelForm):
    class Meta:
        model = Book
        exclude = []
        widgets = {
            "s1": DjangoLookupTableRatingWidget(s1_scores, field_label_in_table=False, weight=15),
            "s2": DjangoLookupTableRatingWidget(s1_scores, allow_input=True),
            "s3": DjangoLookupTableRatingWidget(s1_scores),
            "s4": DjangoLookupTableRatingWidget(s1_scores),

class BookAdmin(admin.ModelAdmin):
    form = BookForm
    list_display = ["title"]

    fieldsets = [
        (None, {
            "fields": ["title"]
        ("Score 1 & 2", {
            "fields": ["s1", "s2"],
        ("Score 3 & 4", {
            "fields": ["s3", "s4"],
    ], BookAdmin)

Widget Init Parameters

  • scores: required.
    • It's a list of map. The map always contains scores and rule item. scores is a list of rating buttons, and the rule is a string of rule description. HTML rule is accepted.
  • allow_input: optional, default to False.
    • If allow_input=True, the final score input is allowed to input.
    • If allow_input=False, the final score input is readonly.
  • field_label_in_table: optional, default True.
    • If field_label_in_table=True, we use jquery to move field's label and help into the table.
    • If field_label_in_table=False, we keep the field's label and help at thire original position.
  • weight: optional, default None.
    • weight means the field weight in full rating form.
    • If not provides, we will remove the weight column.
  • field_label: optional, default to _("Item").
  • final_score_label: optional, default to _("Score").
  • scores_label: optional, default to _("Rating Buttons").
  • rules_label: optional, default to _("Rule").
  • weight_label: _("Weight").
    • All lables are used to render the rating table header.


v0.1.0 2020/03/18

  • First release.

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-lookup-table-rating-widget, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size django-lookup-table-rating-widget-0.1.0.tar.gz (8.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page