Opened 6 years ago

Closed 6 years ago

#10298 closed (fixed)

get_list_or_404 documentation

Reported by: Dagur Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The documentation needs to be fixed (http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#get-list-or-404)

get_list_or_404 is not equivalent to doing:

def my_view(request):
    my_objects = MyModel.objects.filter(published=True) if not my_objects:
        raise Http404

because my_objects is a queryset but the function will return a list.

Attachments (1)

docs-shortcuts.diff (476 bytes) - added by masklinn 6 years ago.
Call to list(), to make the returned queryset into one

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by masklinn

Call to list(), to make the returned queryset into one

comment:1 Changed 6 years ago by Alex

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 6 years ago by russellm

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

(In [9857]) Fixed #10298 -- Corrected the example for the get_list_or_404 shortcut. Thanks to Dagur for the report.

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