diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-04-26 09:30:40 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-04-27 10:37:13 +0200 |
| commit | fbea64b8ce6a82dd34b1f78cb884306455106185 (patch) | |
| tree | a12f81a6caf15143d2a8f04ee136c638d07eedfa /docs | |
| parent | 7ad7034054c10bfa919ceec4623fa7f30a68bba2 (diff) | |
[3.2.x] Refs #32682 -- Renamed use_distinct variable to may_have_duplicates.
QuerySet.distinct() is not the only way to avoid duplicate, it's also
not preferred.
Backport of cd74aad90e09865ae6cd8ca0377ef0a5008d14e9 from main
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 8fc504913b..5196c000a8 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1586,14 +1586,16 @@ templates used by the :class:`ModelAdmin` views: search_fields = ('name',) def get_search_results(self, request, queryset, search_term): - queryset, use_distinct = super().get_search_results(request, queryset, search_term) + queryset, may_have_duplicates = super().get_search_results( + request, queryset, search_term, + ) try: search_term_as_int = int(search_term) except ValueError: pass else: queryset |= self.model.objects.filter(age=search_term_as_int) - return queryset, use_distinct + return queryset, may_have_duplicates This implementation is more efficient than ``search_fields = ('name', '=age')`` which results in a string comparison for the numeric |
