diff options
| author | Tomek Paczkowski <tomek@hauru.eu> | 2013-06-04 23:35:11 +0200 |
|---|---|---|
| committer | Tomek Paczkowski <tomek@hauru.eu> | 2013-06-05 23:08:00 +0200 |
| commit | 0fd9f7c95f748764867dc148a2bacef807466d85 (patch) | |
| tree | a08c8b3d0b96b9a25224844c27457b57e0055eb3 /docs | |
| parent | 4f4e9243e4cf585e32a882804084853108ef94c0 (diff) | |
Fixed #19080 -- Fine-grained control over select_related in admin
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 8f457e77ac..1a5e9f2073 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -812,12 +812,24 @@ subclass:: the list of objects on the admin change list page. This can save you a bunch of database queries. - The value should be either ``True`` or ``False``. Default is ``False``. + .. versionchanged:: dev - Note that Django will use - :meth:`~django.db.models.query.QuerySet.select_related`, - regardless of this setting if one of the ``list_display`` fields is a - ``ForeignKey``. + The value should be either a boolean, a list or a tuple. Default is + ``False``. + + When value is ``True``, ``select_related()`` will always be called. When + value is set to ``False``, Django will look at ``list_display`` and call + ``select_related()`` if any ``ForeignKey`` is present. + + If you need more fine-grained control, use a tuple (or list) as value for + ``list_select_related``. Empty tuple will prevent Django from calling + ``select_related`` at all. Any other tuple will be passed directly to + ``select_related`` as parameters. For example:: + + class ArticleAdmin(admin.ModelAdmin): + list_select_related = ('author', 'category') + + will call ``select_related('author', 'category')``. .. attribute:: ModelAdmin.ordering |
