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)
| 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 | """ |