Opened 14 years ago
Closed 13 years ago
#17156 closed Cleanup/optimization (fixed)
QuerySet.__contains__ needs documentation
| Reported by: | Thomas Güttler | Owned by: | nobody |
|---|---|---|---|
| Component: | Documentation | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | hv@…, sebastian.goll@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The documentation should explain what happens in this code:
if obj in queryset:
....
If queryset is huge, the above code can be very slow.
If you want to run the code in the database, you should use this:
if queryset.filter(pk=obj.pk).exists():
....
Related discussion: http://groups.google.com/group/django-users/browse_thread/thread/5a8196ff1086f4ae/530548a127a6e3ca
Can someone please provide a patch for the documentation. I am not a native speaker, and won't find the right words.
Change History (4)
comment:1 by , 14 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 14 years ago
| Cc: | added |
|---|
comment:4 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The docs should be added to this list: https://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated