diff options
| author | Tim Graham <timograham@gmail.com> | 2016-06-30 09:00:10 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-30 09:00:38 -0400 |
| commit | fe663b3d38fe59a8d922792b11ca05eba1afa575 (patch) | |
| tree | 10593f21a8c61e6f0999a72c3855ba47393fc08a /docs | |
| parent | 67c60cce7073762106bca186669af0fe1f588d15 (diff) | |
[1.9.x] Fixed #26002 -- Explained ModelAdmin.get_search_results() example.
Backport of c9d0a0f7f47c8496a9d8b0cfda94e2ef118d9ab3 from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 58024a5430..1a0ac5ad00 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1389,7 +1389,7 @@ templates used by the :class:`ModelAdmin` views: implemented by your search method may introduce duplicates into the results, and return ``True`` in the second element of the return value. - For example, to enable search by integer field, you could use:: + For example, to search by ``name`` and ``age``, you could use:: class PersonAdmin(admin.ModelAdmin): list_display = ('name', 'age') @@ -1405,6 +1405,11 @@ templates used by the :class:`ModelAdmin` views: queryset |= self.model.objects.filter(age=search_term_as_int) return queryset, use_distinct + This implementation is more efficient than ``search_fields = + ('name', '=age')`` which results in a string comparison for the numeric + field, for example ``... OR UPPER("polls_choice"."votes"::text) = UPPER('4')`` + on PostgreSQL. + .. method:: ModelAdmin.save_related(request, form, formsets, change) The ``save_related`` method is given the ``HttpRequest``, the parent |
