Try this:
Rating.objects.filter(attribute__in=attributes) \
.values('location') \
.annotate(score = Sum('score')) \
.order_by('-score')
More Related Contents:
- Django: Group by date (day, month, year)
- Django 1.11 Annotating a Subquery Aggregate
- How to set a Django model field’s default value to a function call / callable (e.g., a date relative to the time of model object creation)
- How to use permission_required decorators on django class-based views
- Django Admin Show Image from Imagefield
- Django: Get model from string?
- Django: Get list of model fields?
- How do I get Django Admin to delete files when I remove an object from the database/model?
- What’s the recommended approach to resetting migration history using Django South?
- How do I add multiple arguments to my custom template filter in a django template?
- How to automatically login a user after registration in django
- Django model instances primary keys do not reset to 1 after all instances are deleted
- How to fetch static CSS files with django on IIS?
- Check permission inside a template in Django
- 405 POST method not allowed
- How to remove all relations from manytomany?
- How to access outermost forloop.counter with nested for loops in Django templates?
- How to get URL of current page, including parameters, in a template?
- Django: show/log ORM sql calls from python shell
- Can Django automatically create a related one-to-one model?
- Cannot find command ‘git’ – windows
- Make Django forms use comma as decimal separator
- Django – show loading message during long processing
- Django model with 2 foreign keys from the same table
- How to add Check Constraints for Django Model fields?
- Django templates folders
- Django Programming error column does not exist even after running migrations
- Django – Static file not found
- Different db for testing in Django?
- django: how to access current request user in ModelForm?