Opened 7 years ago

Closed 7 years ago

#7840 closed (wontfix)

'get_list_or_404' does not know the slicing

Reported by: spike Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: get_list_or_404
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


To make a story short, see this code.

I have model, Document, it contains 30 objects.


It returns entire objects of Document, but in this case,


Not like a general usage of queryset filtering, get_list_or_404 does not handle the
slicing, it just return the all the objects of model.

To handle the slicing and return Http404 if there are not objects, wrote new
sub-class, 'WrapperQueryset'. See the patched code.

Attachments (1)

get_list_or_404_r7997.patch (1.2 KB) - added by spike 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by spike

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

You've changed this function entirely; the name is now misleading. It no longer returns a list -- it returns some kind of queryset.

Since it's such a minor function and so easy to just do a normal queryset and check it for emptiness (or write your own helper function), it's not worth complicating things for the case where it slicing has to be done as part of the query, instead of back in Python. In the former case, just use the normal query interface.

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