MCPcopy
hub / github.com/django/django / aget_list_or_404

Function aget_list_or_404

django/shortcuts.py:154–170  ·  view source on GitHub ↗

See get_list_or_404().

(klass, *args, **kwargs)

Source from the content-addressed store, hash-verified

152
153
154async def aget_list_or_404(klass, *args, **kwargs):
155 """See get_list_or_404()."""
156 queryset = _get_queryset(klass)
157 if not hasattr(queryset, "filter"):
158 klass__name = (
159 klass.__name__ if isinstance(klass, type) else klass.__class__.__name__
160 )
161 raise ValueError(
162 "First argument to aget_list_or_404() must be a Model, Manager, or "
163 f"QuerySet, not '{klass__name}'."
164 )
165 obj_list = [obj async for obj in queryset.filter(*args, **kwargs)]
166 if not obj_list:
167 raise Http404(
168 _("No %s matches the given query.") % queryset.model._meta.object_name
169 )
170 return obj_list
171
172
173def resolve_url(to, *args, **kwargs):

Callers 2

test_get_list_or_404Method · 0.90

Calls 3

Http404Class · 0.90
_get_querysetFunction · 0.85
filterMethod · 0.45

Tested by 2

test_get_list_or_404Method · 0.72