https://github.com/django/django/pull/13038
Above pull request (Ticket #24141) has a discussion on how to handle
qs.contains() for QuerySets with qs.values() or qs.values_list() calls.
Current patch checks self._result_cache if exists and iterable class is
ModelIterable, otherwise returns .filt
should write:
>
> if obj in list(queryset):
>
> Which I understand is already working? Why does the first line (without
> list()) should work anyway?
>
> And if users want performance, why not write:
>
> if queryset.filter(pk=obj.pk).exists():
> אורי
> u...@speedy.net
efetched obj_first in qs: 0.030961711003328674
Prefetched obj_mid in qs: 6.6988333979970776
Prefetched obj_last in qs: 24.18991441695
Database obj_first exists(): 6.468764332996216
Database obj_mid exists(): 6.167532913001196
Database obj_last exists(): 6.0190791100030765
Le mer. 3 juin 2020 à 10:52,
to a topic in the
> Google Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-developers/NZaMq9BALrs/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an ema
Is there a specific reason Djangos QuerySet does not implement
__contains__? It doesn't seem very complicated to me, but maybe I'm missing
something.
When checking if an object is in e queryset I always use code lite this:
if queryset.filter(pk=obj.pk).exists():
The pythonic way would be:
if ob
autoescape=False,
email_formatter: callable = None,
url_formatter: callable = None,
):
...
Johan Schiff
Betahaus (SE)
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To un