Well, since you are using Django ORM, you probably do not want to do this "by SQL query."
If you always want to order them (by default) this way, I would think that the best solution would be to put the ordering attribute in your pass-through Meta inner class model:
class AlbumRegionReleaseDate(models.Model): album = models.ForeignKey(Album) region = models.ForeignKey(Region) digital_release_date = models.DateField() class Meta: ordering = ('region', 'digital_release_date')
If you need only one query that does this without using the default order ... I need to think about it more.
source share