Created
March 4, 2017 06:43
-
-
Save sivabudh/00801ab59bd09325e5d92c32a99f89d8 to your computer and use it in GitHub Desktop.
How to query for Min and Max at the same time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from django.db.models import Max, Min | |
>>> Store.objects.annotate(min_price=Min('books__price'), max_price=Max('books__price')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment