Fixed #8408 -- Added ModelAdmin.show_full_result_count to avoid COUNT() query.

Thanks lidaobing for the suggestion.
This commit is contained in:
Thomas Chaumeny 2014-09-22 18:46:43 +02:00 committed by Tim Graham
parent d1ca70110f
commit 17557d068c
8 changed files with 50 additions and 7 deletions

View file

@ -1160,6 +1160,19 @@ subclass::
:meth:`ModelAdmin.get_search_results` to provide additional or alternate
search behavior.
.. attribute:: ModelAdmin.show_full_result_count
.. versionadded:: 1.8
Set ``show_full_result_count`` to control whether the full count of objects
should be displayed on a filtered admin page (e.g. ``99 results (103 total)``).
If this option is set to ``False``, a text like ``99 results (Show all)``
is displayed instead.
The default of ``show_full_result_count=True`` generates a query to perform
a full count on the table which can be expensive if the table contains a
large number of rows.
.. attribute:: ModelAdmin.view_on_site
.. versionadded:: 1.7

View file

@ -72,6 +72,10 @@ Minor features
<django.contrib.admin.AdminSite.site_url>` in order to display a link to the
front-end site.
* You can now specify :attr:`ModelAdmin.show_full_result_count
<django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether
or not the full count of objects should be displayed on a filtered admin page.
:mod:`django.contrib.auth`
^^^^^^^^^^^^^^^^^^^^^^^^^^