Created
September 8, 2023 18:24
-
-
Save tim-schilling/f5d90279754e288e0e4e2df9e2a2811b to your computer and use it in GitHub Desktop.
Subquery Count
This file contains hidden or 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 IntegerField, Subquery | |
class SubqueryCount(Subquery): | |
template = "(SELECT COUNT(*) FROM (%(subquery)s) _count)" | |
output_field = IntegerField() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment