Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. The easiest way to order by ratings is to add a GenericRelation to the Rating model from your model:
  2.  
  3. from django.contrib.contenttypes.fields import GenericRelation
  4. from star_ratings.models import Rating
  5.  
  6. class Foo(models.Model):
  7.     bar = models.CharField(max_length=100)
  8.     ratings = GenericRelation(Rating, related_query_name='foos')
  9.  
  10. Foo.objects.filter(ratings__isnull=False).order_by('ratings__average')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top