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

Method get_queryset

rest_framework/generics.py:52–77  ·  view source on GitHub ↗

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using `self.queryset`. This method should always be used rather than accessing `self.queryset` directly, as `self.queryset` gets evaluated only once, and those

(self)

Source from the content-addressed store, hash-verified

50 return cls
51
52 def get_queryset(self):
53 """
54 Get the list of items for this view.
55 This must be an iterable, and may be a queryset.
56 Defaults to using `self.queryset`.
57
58 This method should always be used rather than accessing `self.queryset`
59 directly, as `self.queryset` gets evaluated only once, and those results
60 are cached for all subsequent requests.
61
62 You may want to override this if you need to provide different
63 querysets depending on the incoming request.
64
65 (Eg. return a list of items that is specific to the user)
66 """
67 assert self.queryset is not None, (
68 "'%s' should either include a `queryset` attribute, "
69 "or override the `get_queryset()` method."
70 % self.__class__.__name__
71 )
72
73 queryset = self.queryset
74 if isinstance(queryset, QuerySet):
75 # Ensure queryset is re-evaluated on each request.
76 queryset = queryset.all()
77 return queryset
78
79 def get_object(self):
80 """

Callers 1

get_objectMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected