With the following code:
from django.db import models
class Blogpost(models.Model): pass
class Vote(models.Model):
question = models.ForeignKey(Blogpost)
TYPE_CHOICES = (
('up', 'Up-Votes'),
('dn', 'Down-Votes'),
)
type = models.CharField(max_length=2, choices=TYPE_CHOICES)
What is the best way to obtain a set of all Blogposts, ordered by up-votes first, then down-votes, without writing SQL through the QuerySet.extra() function?