Here is the story so far
class Rating(models.Model):
positive_rating = models.FloatField(default=0)
negative_rating = models.FloatField(default=0)
class Book(models.Model):
year_pub = models.IntegerField(max_length=4)
category = models.ForeignKey(Category)
rating = models.ForeignKey(Rating)
hash_id = models.CharField(max_length=64, null=True, blank=True)
There are few books. Each will be having 2 types of rating. +ve one and -ve one,
The rating is done using "stars". If +ve rating is done, -ve field will be 0 vice versa.
votes could be simple stored in this way
o = Book.objects.get(pk=1)
o.rating.positive_rating += 2.5
o.rating.save()
Here comes the actual trouble -->
1. How to count the number of ratings
2. How to know which user has voted
3. How to know whether the user has previously voted or not
Typically, how to attach this MyUser (example) model to the Rating Model?
Thanks