Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The easiest way to order by ratings is to add a GenericRelation to the Rating model from your model:
- from django.contrib.contenttypes.fields import GenericRelation
- from star_ratings.models import Rating
- class Foo(models.Model):
- bar = models.CharField(max_length=100)
- ratings = GenericRelation(Rating, related_query_name='foos')
- Foo.objects.filter(ratings__isnull=False).order_by('ratings__average')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement