It seems i cannot use annotate and extra together when making a queryset This
discussions = game.gamediscussion_set.filter(reply_to=None).annotate(up_votes = Count('userUpVotes'), down_votes=Count('userDownVotes')).extra(select={'votes':"'userUpVotes' - 'userDownVotes'"}).order_by('votes')
returns
Caught Warning while rendering: Truncated incorrect DOUBLE value: 'userUpVotes'
I want to add both userUpVotes and userDownVotes together to get a 'votes' field, then order by this field.
userUpVotes is a related ManyToManyField of users (as is userDownVotes). So i need to count these first.
Any ideas?