HighLife
HighLife

Reputation: 4344

Adding star rating to Django comments

I'd like to modify the existing Django comments framework to include star ratings. The Django site has good documentation on modifying the comments framework here, but I still have a few questions.

  1. Unfortunately I don't have much experience modifying forms. If I wanted to incorporate the jQuery star rating plugin into my form how would I go about doing that?
  2. When creating my custom comment model I assume a IntegerField or a FloatField would be best to store the rating?
  3. Should I write a validator to verify that the rating is between 0-5 or whatever the range ends up being, or will I not have to worry about that because the star ratings will only go 0-5?

Upvotes: 0

Views: 1336

Answers (1)

Zashas
Zashas

Reputation: 766

  1. You can set HTML attributes into your inputs (class="star") as described here : https://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs

  2. Probably a IntegerField, keep it simple.

  3. No, a user could hack the javascript and submit any value. Never trust user input ! Write your own validator :)

Upvotes: 2

Related Questions