python - How to access cookie and IP fields in DjangoRatings? -


i'm using djangoratings library found here , have running , set up. in views.py file have button executes line of code when pushed:

     myinstance.rating.add(score=1, user=request.user, ip_address=request.meta['remote_addr'], request.cookies) 

everything works fine. backend works, columns updated votes etc etc, how can access/call ip , cookie fields , columns in djangoratings can write quick if condition refuses run 'add' line if cookies , ip have voted?

thanks in advance help. i've been struggling lot.

myinstance.rating contains method get_ratings() - returns queryset calculate votes related object. can extend retrive necessary information. example:

# it's lazy object rating = myinstance.rating.get_ratings()  # additional query db if not rating.filter(user=user, ip_address=request.meta['remote_addr']).exists():     ... 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -