Given django models A and B:
class A(models.Model):
things = models.ManyToManyField('B')
class B(models.Model):
score = models.FloatField()
text = models.CharField(max_length=100)
How do I get a list of A entities ordered by the text of the highest-scoring B in things?
If I understand you correctly, this should do it.
listwill contain a list of all the objects of model A sorted by the text of each object’s highest scoring thing.There might be a prettier way to write it, but I can’t think of one off the top of my head…