I'm using the djangoratings library found here and I have everything running and set up. In my views.py file I have a button which executes this line of code when pushed:
myinstance.rating.add(score=1, user=request.user, ip_address=request.META['REMOTE_ADDR'], request.COOKIES)
Everything works fine. The backend works, my columns are updated with the votes etc etc, but how can I access/call the IP and cookie fields and columns in djangoratings so that I can write a quick if condition that refuses to run the 'add' line if the cookies and IP have already voted?
Thanks in advance for any help. I've been really struggling with this a lot.
myinstance.rating contains method get_ratings()
- which returns queryset to calculate all votes related to object. You can easily extend it for retrive necessary information. For example:
# it's lazy object
rating = myinstance.rating.get_ratings()
# do additional query for db
if not rating.filter(user=user, ip_address=request.META['REMOTE_ADDR']).exists():
...