开发者

Django-Secretballot does not work?

开发者 https://www.devze.com 2023-03-06 16:46 出处:网络
I am using Django-secretballot app which allows anonymous voting. First we register a model for secret voting and then there is a function add_vote() which takes 2 arguments. \'Token\' and vote value(

I am using Django-secretballot app which allows anonymous voting. First we register a model for secret voting and then there is a function add_vote() which takes 2 arguments. 'Token' and vote value(+1 or -1).

from docs:

add_vote:

function that takes a token and a vote (+1 or -1) and adds or updates the vote for said token (can be renamed by passing add_vote_name parameter to enable_voting_on)

What am I supposed to pass in as 'Token'? I used this in my views.py

t=request.META['REMOTE_ADDR']
feed.add_vote(t,+1)

Yet it does not work. I mean if I try voting from different machines, only first vote gets counted. But it does not get incremented when other vote for that same feed.

Anyone w开发者_如何转开发ho has used this app or figured out what I am doing wrong by checking the doc. Please help.


I'm the author and although I haven't actively developed it recently I hope you find it useful.

token can be any unique string you require, generally speaking what you have should work but there's a chance you're behind a proxy or there's another issue with REMOTE_ADDR in your server config (which is beyond what I'd be able to assist with)

Check that the value of REMOTE_ADDR is actually changing, also consider using a combination of REMOTE_ADDR and something else like a User Agent or unique value stored in a cookie.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号