Fixed #29943 -- Doc'd that admin changelist may add pk to ordering.

This commit is contained in:
Hasan Ramezani 2019-02-13 03:35:49 +01:00 committed by Tim Graham
parent 3b64e2b775
commit f63811f481
1 changed files with 11 additions and 0 deletions

View File

@ -1037,6 +1037,17 @@ subclass::
If you need to specify a dynamic order (for example depending on user or If you need to specify a dynamic order (for example depending on user or
language) you can implement a :meth:`~ModelAdmin.get_ordering` method. language) you can implement a :meth:`~ModelAdmin.get_ordering` method.
.. admonition:: Performance considerations with ordering and sorting
To ensure a deterministic ordering of results, the changelist adds
``pk`` to the ordering if it can't find a single or unique together set
of fields that provide total ordering.
For example, if the default ordering is by a non-unique ``name`` field,
then the changelist is sorted by ``name`` and ``pk``. This could
perform poorly if you have a lot of rows and don't have an index on
``name`` and ``pk``.
.. attribute:: ModelAdmin.paginator .. attribute:: ModelAdmin.paginator
The paginator class to be used for pagination. By default, The paginator class to be used for pagination. By default,