Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Downvote -1 #11

Closed
Brotakuu opened this issue Jun 30, 2015 · 4 comments
Closed

Make Downvote -1 #11

Brotakuu opened this issue Jun 30, 2015 · 4 comments

Comments

@Brotakuu
Copy link

Is it possible to make downvote decrement 1, instead of just removing the upvote?

So negative numbers is possible. And down voting without upvoting is possible.

@shellfly
Copy link
Owner

shellfly commented Jul 1, 2015

For the present, the Vote model can't implement the downvote function. To implement this you have to add another field to record the upvote or downvote action。

@Humper
Copy link

Humper commented Aug 6, 2015

It's not as easy as just adding another field, because both your upvote and downvote field will end up going through the Vote class, so when a user upvotes and you try to do:

obj.upvotes.up(user)
obj.downvotes.down(user)

the second call destroys the first vote.

I made a trivial subclass of Vote called Downvote, and made my downvotes field thusly:

downvotes = VotingManager(through=Downvote)

which does the right thing, but now I'm running into other issues; specifically that Django can't filter on GenericForeignKeys, so code like:

self.through.objects.filter(user=user, content_object=self.instance).delete()

doesn't work -- it generates the error:

FieldError: Field 'content_object' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.

This is with Django 1.8.3.

@shellfly
Copy link
Owner

#43

@shellfly
Copy link
Owner

shellfly commented Feb 9, 2017

Supported in version 2.1.4

@shellfly shellfly closed this as completed Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants