MCPcopy Index your code
hub / github.com/encode/django-rest-framework / get_object_or_404

Function get_object_or_404

rest_framework/generics.py:13–21  ·  view source on GitHub ↗

Same as Django's standard shortcut, but make sure to also raise 404 if the filter_kwargs don't match the required types.

(queryset, *filter_args, **filter_kwargs)

Source from the content-addressed store, hash-verified

11
12
13def get_object_or_404(queryset, *filter_args, **filter_kwargs):
14 """
15 Same as Django's standard shortcut, but make sure to also raise 404
16 if the filter_kwargs don't match the required types.
17 """
18 try:
19 return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
20 except (TypeError, ValueError, ValidationError):
21 raise Http404
22
23
24class GenericAPIView(views.APIView):

Callers 2

get_objectMethod · 0.85
get_objectMethod · 0.85

Calls

no outgoing calls

Tested by 1

get_objectMethod · 0.68