How to use Star rating of Font-awesome with Django?

Houman picture Houman · Oct 6, 2012 · Viewed 75.2k times · Source

Fontawesome has a great star rating css extension, which looks really awesome.

However clicking on any of the span elements wouldn't really do anything. I don't know how to hook this up with my database model. Lets say I have an integer field of 0-5 in Django. How could I set the value according to the user's selection within the template?

enter image description here

<span class="rating">
  <span class="star"></span>
  <span class="star"></span>
  <span class="star"></span>
  <span class="star"></span>
  <span class="star"></span>
</span>

Answer

Houman picture Houman · Nov 3, 2012

I ended up using Raty. If you are looking for a simple and clean solution, I found this the easiest.

$('#star').raty('score');                   // Get the current score.