Code

Opened 3 years ago

Closed 22 months ago

#17156 closed Cleanup/optimization (fixed)

QuerySet.__contains__ needs documentation

Reported by: guettli 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.

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by sebastian

  • Cc sebastian.goll@… added

comment:4 Changed 22 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In [d823bb790d3b70e19e7f8bc7cfb11f3a1728a799]:

Fixed #17156 -- Added documentation examples for exists()

Thanks mrmagooey for the draft patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.