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.
* status: new => closed
* resolution: => wontfix
Comment:
This might have been proposed before but I couldn't find a discussion.
I doubt there would be consensus for breaking with the Zen of Python
("There should be one-- and preferably only one --obvious way to do it.")
but you can propose it on the DevelopersMailingList.
--
Ticket URL: <https://code.djangoproject.com/ticket/30118#comment:1>
* has_patch: 0 => 1
Comment:
On the [https://github.com/django/django/pull/10866 PR], Simon and Nick
also supported the wontfix decision.
--
Ticket URL: <https://code.djangoproject.com/ticket/30118#comment:2>