Closed MysteryCoder456 closed 4 years ago
There are two fields called num_vote_up
and num_vote_down
on the VoteModel model that you can use when inheriting from it
I also want to know how to check whether the user has up or downvoted.
The simple way is documented on the README
# Check if the user already voted the object
review.votes.exists(user_id)
You can also pass a second optional parameter, check the code here: https://github.com/shellfly/django-vote/blob/f628a49c5e1e2ac2a91ac87922936e71d9b48523/vote/managers.py#L140-L145
If you have a list of objects that you want to attach is_vote_up
and is_vote_down
on them and don't want to query them one by one, you can use the add_field_to_objects
helper function.
https://github.com/shellfly/django-vote/blob/dc9d167e3aaf63d859b09917e0b8ebb594a4fdac/vote/utils.py#L17-L32
Ok thanks a lot!
I also want to know how to check whether the user has up or downvoted.