MCPcopy
hub / github.com/django/django / get_results

Method get_results

django/contrib/admin/views/main.py:297–336  ·  view source on GitHub ↗
(self, request)

Source from the content-addressed store, hash-verified

295 return "?%s" % urlencode(sorted(p.items()), doseq=True)
296
297 def get_results(self, request):
298 paginator = self.model_admin.get_paginator(
299 request, self.queryset, self.list_per_page
300 )
301 # Get the number of objects, with admin filters applied.
302 result_count = paginator.count
303
304 # Get the total number of objects, with no admin filters applied.
305 # Note this isn't necessarily the same as result_count in the case of
306 # no filtering. Filters defined in list_filters may still apply some
307 # default filtering which may be removed with query parameters.
308 if self.model_admin.show_full_result_count:
309 full_result_count = self.root_queryset.count()
310 else:
311 full_result_count = None
312 can_show_all = result_count <= self.list_max_show_all
313 multi_page = result_count > self.list_per_page
314
315 # Get the list of objects to display on this page.
316 if (self.show_all and can_show_all) or not multi_page:
317 result_list = self.queryset._clone()
318 else:
319 try:
320 result_list = paginator.page(self.page_num).object_list
321 except InvalidPage:
322 raise IncorrectLookupParameters
323
324 self.result_count = result_count
325 self.show_full_result_count = self.model_admin.show_full_result_count
326 # Admin actions are shown if there is at least one entry
327 # or if entries are not counted because show_full_result_count is
328 # disabled
329 self.show_admin_actions = not self.show_full_result_count or bool(
330 full_result_count
331 )
332 self.full_result_count = full_result_count
333 self.result_list = result_list
334 self.can_show_all = can_show_all
335 self.multi_page = multi_page
336 self.paginator = paginator
337
338 def _get_default_ordering(self):
339 ordering = []

Calls 4

pageMethod · 0.80
get_paginatorMethod · 0.45
countMethod · 0.45
_cloneMethod · 0.45