模型.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)
查看.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 字段有资格获得两个分数,我应该如何更改分数以便我可以实现投票赞成和投票反对功能,在投票赞成时,我应该能够在现有分数上加 1,而在投票反对时我应该可以减去一票,请帮助,提前谢谢