models.py
class Restaurant(models.Model)
food_rating = RatingField(range=2, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
service_rating = RatingField(range=2, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
ambience_ratiing = RatingField(range=2, weight=5,can_change_vote = True,allow_delete = True,allow_anonymous = True)
view.py代码
r = Restaurant.objects.get(pk=1)
r.food_rating.add(score = -1 , user = request.user , ip_address =request.META.get('HTTP_REFERER'))
print r.food_rating.score
错误
djangoratings.exceptions.InvalidRating: -1 is not a valid choice for food_rating
疑问
我food_rating场有资格参加两个分数,我该如何c将比分提高,以便我可以实施投票并投票下来功能,在投票上,我应该能够将现有比分加1,然后投票下来,我应该可以减去投票,请提前致谢,请提前致谢Django的评级程序,负得分
Is RatingField是一个自定义字段吗? – Dave
我使用djangoratings应用程序,https://github.com/dcramer/django-ratings – Abhimanyu