#24141: contains() method for QuerySets
-------------------------------------+-------------------------------------
Reporter: gormster | Owner:
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by carljm):
Tim, I wouldn't say the discussion on that PR settled the question of
whether `QuerySet.contains()` is a useful feature or not.
I think the original PR (to implement `QuerySet.__contains__()` as
`.filter(pk=obj.pk).exists()` under the hood) is a non-starter, but adding
`Queryset.contains()` seems reasonable to me. Gormster is right that there
are a number of questions on SO with people confused about how to
efficiently check for object containment in a queryset, and that M2M
relationships present a not-uncommon use case for it. My inclination would
be slightly in favor of adding it, if gormster updated the patch with
tests and docs. But I'm interested in what others think.
--
Ticket URL: <https://code.djangoproject.com/ticket/24141#comment:4>
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/066.0246917067b38e0269581ccbad0e9243%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.