Oh, of course I forget about new aggregation support in Django and its annotate
functionality.
So query may look like this:
Contest.objects.get(pk=id).image_set.annotate(score=Sum('vote__value')).order_by( 'score' )
More Related Contents:
- OperationalError: database is locked
- multiple databases and multiple models in django
- Django persistent database connection
- How do you join two tables on a foreign key field using django ORM?
- How to make/use a custom database function in Django
- How to see the raw SQL queries Django is running?
- How to move a model between two Django apps (Django 1.7)
- sqlite3.OperationalError: unable to open database file
- Race conditions in django
- What is your favorite solution for managing database migrations in django? [closed]
- django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
- Django: Increment blog entry view count by one. Is this efficient?
- django makemigrations and migrate on heroku server don’t create tables
- Django dynamic model fields
- Django filter queryset __in for *every* item in list
- How to execute a Python script from the Django shell?
- Django, creating a custom 500/404 error page
- Django: Redirect to previous page after login
- How do I force Django to ignore any caches and reload data?
- Django Rest Framework writable nested serializers
- How can I save my secret keys and password securely in my version control system?
- get request data in Django form
- Calling a REST API from django view
- Django – makemigrations – No changes detected
- How does the order of mixins affect the derived class?
- Django widget override template
- Run manage.py from AWS EB Linux instance
- How to perform filtering with a Django JSONField?
- Multiple lookup_fields for django rest framework
- Apache mod_wsgi error: Forbidden You don’t have permission to access / on this server