#30118: Add support for filter arguments in queryset.exists() and 
queryset.count()
-------------------------------------+-------------------------------------
               Reporter:  Sjoerd     |          Owner:  nobody
  Job Postmus                        |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  master
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Currently, both .exists() and .count() do not support any arguments.

 I would very much enjoy being able to write

 {{{
 if SomeModel.objects.exists(field=value):
 }}}

 instead of

 {{{
 if SomeModel.objects.filter(field=value).exists():
 }}}

 and similarly for count.

 Especially when the "search" part of the query is more complex, it would
 allow one to write

 {{{
 number_of_superusers_in_group = User.objects.count(
     is_superuser=True,
     group=group,
 )
 }}}

 which I find visually more appealing over

 {{{
 number_of_superusers_in_group = User.objects.filter(
     is_superuser=True,
     group=group,
 ).count()
 }}}

 because of the strange "method-call" on the last line.

 As it seems fairly obvious to me, and also fairly simple to implement, I
 suspect there might be something I'm missing as to why it's not a good
 idea, and it might already have been documented, but I can not find it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30118>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.a0dca04da11d4640fda7590f95fed423%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to