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
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment