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 - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -