Opened 4 years ago

Closed 3 years ago

#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

Description

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 4 years ago.

Download all attachments as: .zip

Change History (12)

by Caram, 4 years ago

Attachment: search_help_text.jpg added

comment:1 by Virtosu Bogdan, 4 years ago

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 by Carlton Gibson, 4 years ago

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 by Mariusz Felisiak, 4 years ago

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

comment:4 by Nick Pope, 4 years ago

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 by Girish Sontakke, 4 years ago

Owner: changed from nobody to Caram
Status: newassigned

comment:6 by Hasan Ramezani, 3 years ago

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

comment:7 by Caram, 3 years ago

Thanks @Hasan!

comment:8 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

comment:9 by Hasan Ramezani, 3 years ago

Patch needs improvement: unset

comment:10 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

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