(self, request, *args, **kwargs)
| 155 | """ |
| 156 | |
| 157 | def get(self, request, *args, **kwargs): |
| 158 | self.object_list = self.get_queryset() |
| 159 | allow_empty = self.get_allow_empty() |
| 160 | |
| 161 | if not allow_empty: |
| 162 | # When pagination is enabled and object_list is a queryset, |
| 163 | # it's better to do a cheap query than to load the unpaginated |
| 164 | # queryset in memory. |
| 165 | if self.get_paginate_by(self.object_list) is not None and hasattr( |
| 166 | self.object_list, "exists" |
| 167 | ): |
| 168 | is_empty = not self.object_list.exists() |
| 169 | else: |
| 170 | is_empty = not self.object_list |
| 171 | if is_empty: |
| 172 | raise Http404( |
| 173 | _("Empty list and “%(class_name)s.allow_empty” is False.") |
| 174 | % { |
| 175 | "class_name": self.__class__.__name__, |
| 176 | } |
| 177 | ) |
| 178 | context = self.get_context_data() |
| 179 | return self.render_to_response(context) |
| 180 | |
| 181 | |
| 182 | class MultipleObjectTemplateResponseMixin(TemplateResponseMixin): |
no test coverage detected