#32543 closed New feature (fixed)

Add `search_help_text` to `admin.ModelAdmin`

Reported by: Caram Owned by: Hasan Ramezani
Component: contrib.admin Version: 4.0
Severity: Normal Keywords: admin search_fields
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes


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.

Attachments (1)

search_help_text.jpg (10.4 KB) - added by Caram 19 months ago.

Download all attachments as: .zip

Change History (12)

Changed 19 months ago by Caram

Attachment: search_help_text.jpg added

comment:1 Changed 19 months ago 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.

comment:2 Changed 19 months ago by Carlton Gibson

Triage Stage: UnreviewedAccepted

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. 🙂

comment:3 Changed 19 months ago by Mariusz Felisiak

Needs documentation: set
Needs tests: set
Patch needs improvement: set

comment:4 Changed 19 months ago 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.

comment:5 Changed 18 months ago by Girish Sontakke

Owner: changed from nobody to Caram
Status: newassigned

comment:6 Changed 17 months ago by Hasan Ramezani

Needs documentation: unset
Needs tests: unset
Owner: changed from Caram to Hasan Ramezani
Patch needs improvement: unset

comment:7 Changed 17 months ago by Caram

Thanks @Hasan!

comment:8 Changed 17 months ago by Mariusz Felisiak

Patch needs improvement: set

comment:9 Changed 16 months ago by Hasan Ramezani

Patch needs improvement: unset

comment:10 Changed 16 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:11 Changed 16 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 1143f3b:

Fixed #32543 -- Added search_help_text to ModelAdmin.

Note: See TracTickets for help on using tickets.
Back to Top