Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#20965 closed Uncategorized (invalid)

Why do DetailView use .filter() instead of .get()?

Reported by: anonymous Owned by: nobody
Component: Generic views Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.views.generic.detail in the get_object() method it will do; queryset = queryset.filter() and I wonder why it doesn't .get()?

https://github.com/django/django/blob/master/django/views/generic/detail.py#L21

Change History (3)

comment:1 Changed 5 years ago by anonymous

Component: UncategorizedGeneric views

comment:2 Changed 5 years ago by Tim Graham

Resolution: invalid
Status: newclosed

There's a get() call on line 52, after various filter()s have been applied. This ticket tracker isn't really the place to ask these questions though, please see https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels.

comment:3 Changed 5 years ago by anonymous

I see, I'm so sorry for that.

Note: See TracTickets for help on using tickets.
Back to Top