[Django] #32543: Add `search_help_text` to `admin.ModelAdmin`

152 views
Skip to first unread message

Django

unread,
Mar 12, 2021, 8:11:26 AM3/12/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
caramdache |
Type: New | Status: new
feature |
Component: | Version: 4.0
contrib.admin |
Severity: Normal | Keywords: admin search_fields
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 1 |
-------------------------------------+-------------------------------------
The admin `changelist_view` has a search box, but the user does not know
which fields will be searched. They can only find out by trial and error.

There is a need for users to know which fields will be searched.

This patch [https://github.com/django/django/pull/14117] adds a new
`search_help_text` field to `ModelAdmin` that will display a help text
below the search bar.

--
Ticket URL: <https://code.djangoproject.com/ticket/32543>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 12, 2021, 8:17:41 AM3/12/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: caramdache | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:

Keywords: admin search_fields | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by caramdache):

* Attachment "search_help_text.jpg" added.

Django

unread,
Mar 13, 2021, 6:41:48 AM3/13/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: nobody

Type: New feature | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Virtosu Bogdan):

This would have been useful a lot of times. Thank you!
It would work well the way it's implemented now, but I have a couple of
minor suggestions/questions.

The default could be something like "Search by <search field labels>" and
you can opt out or change the text yourself by defining search_help_text.
I guess this depends on how many people would find this useful.
Couldn't the placeholder attribute on input be used for it ? It seems to
be a common pattern and then changing the default behavior would be even
less disruptive.

--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:1>

Django

unread,
Mar 16, 2021, 4:42:26 AM3/16/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+------------------------------------
Reporter: Caram | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Maybe the placeholder idea (and disabling) is worth looking at, but the
basic idea from the screenshot seems nice enough, so let's accept.

Caram, I didn't look at the patch in detail yet, but do go over the patch
review checklist that was linked in the comment on the PR. Look at the
naming, which should begin `Fixed #32543 -- ...` which let's us auto-link
back to the PR from here, and other similar conveniences. 🙂

--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:2>

Django

unread,
Mar 17, 2021, 3:17:23 AM3/17/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+------------------------------------
Reporter: Caram | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 1
-------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:3>

Django

unread,
Mar 17, 2021, 4:57:27 AM3/17/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+------------------------------------
Reporter: Caram | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 1
-------------------------------------+------------------------------------

Comment (by Nick Pope):

This is a good idea, I too have often wondered what I am able to search
by.

The current implementation in the PR is only allowing some free-form text
to be set. I think it can be useful to allow this, but the default should
be to create a `@property` on the base class that uses the contents of
`search_fields`. This will require looking up the `verbose_name` on the
model's field based on the value in `search_fields`.

My concern about not doing this in an automated way by default is that
`search_fields` will become out of sync with `search_help_text` which will
be a worse situation than the status quo.

The placeholder idea element is nice, but if there are more than about 3
fields we'll not be able to see the entire placeholder. Again, perhaps
more misleading than helpful.

--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:4>

Django

unread,
Apr 15, 2021, 12:34:31 AM4/15/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+------------------------------------
Reporter: Caram | Owner: Caram
Type: New feature | Status: assigned

Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 1
-------------------------------------+------------------------------------
Changes (by Girish Sontakke):

* owner: nobody => Caram
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:5>

Django

unread,
May 19, 2021, 5:58:49 PM5/19/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: Hasan
| Ramezani

Type: New feature | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: Caram => Hasan Ramezani
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:6>

Django

unread,
May 20, 2021, 8:58:30 AM5/20/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Caram):

Thanks @Hasan!

--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:7>

Django

unread,
May 21, 2021, 2:02:10 AM5/21/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:8>

Django

unread,
May 25, 2021, 3:25:50 PM5/25/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:9>

Django

unread,
May 26, 2021, 4:18:40 AM5/26/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: Hasan
| Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin search_fields | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:10>

Django

unread,
May 26, 2021, 4:56:08 AM5/26/21
to django-...@googlegroups.com
#32543: Add `search_help_text` to `admin.ModelAdmin`
-------------------------------------+-------------------------------------
Reporter: Caram | Owner: Hasan
| Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: fixed

Keywords: admin search_fields | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1143f3bb5ecaa2be58f2cd9077f147040291659d" 1143f3b]:
{{{
#!CommitTicketReference repository=""
revision="1143f3bb5ecaa2be58f2cd9077f147040291659d"
Fixed #32543 -- Added search_help_text to ModelAdmin.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32543#comment:11>

Reply all
Reply to author
Forward
0 new messages