Opened 10 years ago

Closed 10 years ago

#7840 closed (wontfix)

'get_list_or_404' does not know the slicing

Reported by: Spike^ekipS 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: no UI/UX: no


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^ekipS 10 years ago.

Download all attachments as: .zip

Change History (2)

Changed 10 years ago by Spike^ekipS

Attachment: get_list_or_404_r7997.patch added

comment:1 Changed 10 years ago by Malcolm Tredinnick

Resolution: wontfix
Status: newclosed

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