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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -