Opened 5 years ago

Closed 18 months ago

Last modified 16 months ago

#26761 closed New feature (wontfix)

Add 'help_text' property to methods in ModelAdmin.list_display

Reported by: Derek Hohls Owned by: Hasan Ramezani
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Guille López, Carlton Gibson Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

It would be helpful to allow for a help_text property to be supplied to a custom field in the admin.

For example:

from django.contrib import admin

class AuthorAdmin(admin.ModelAdmin):
    fields = ('name', 'title', 'view_birth_date')

    def view_birth_date(self, obj):
        return obj.birth_date

    view_birth_date.help_text = 'Authors birthday'

This help text could be displayed via a 'hover over' in the header(s) of the columns in the admin list display.

Change History (19)

comment:1 Changed 5 years ago by Tim Graham

Description: modified (diff)
Keywords: admin removed
Summary: Admin - add 'help_text' property to custom fieldsAdd 'help_text' property to methods in ModelAdmin.list_display
Triage Stage: UnreviewedAccepted

comment:2 Changed 5 years ago by ducdetronquito

Owner: changed from nobody to ducdetronquito
Status: newassigned

comment:3 Changed 5 years ago by ducdetronquito

Hi,

I have made a Pull-Request for this ticket (Cf. https://github.com/django/django/pull/6880)

I am looking forward to have a review and made some changes if need be :)

comment:4 Changed 5 years ago by Tim Graham

Has patch: set

comment:5 Changed 5 years ago by ducdetronquito

Hi there,

I made some changes suggested by @profuel.
Now the PR passes all the tests \o/

Do not hesitate to tell me if something could be improved !

comment:6 Changed 5 years ago by Tim Graham

Patch needs improvement: set

I left some ideas for improvement on the PR.

comment:7 Changed 3 years ago by Guille López

Owner: changed from ducdetronquito to Guille López
Version: 1.9master

Since it has been a while since this problem it's posted and the required fixes of the sent PR seems stalled.... I'm taking ownership of it to send a new PR that covers the feature and the suggestions addressed in the old PR.

comment:8 Changed 3 years ago by Guille López

Cc: Guille López added

comment:9 Changed 23 months ago by Hasan Ramezani

Owner: changed from Guille López to Hasan Ramezani

comment:10 Changed 23 months ago by Hasan Ramezani

Patch needs improvement: unset
Last edited 23 months ago by Mariusz Felisiak (previous) (diff)

comment:11 Changed 18 months ago by Mariusz Felisiak

Needs tests: set
Patch needs improvement: set

comment:12 Changed 18 months ago by Hasan Ramezani

Needs tests: unset
Patch needs improvement: unset

comment:13 Changed 18 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In fbe82f82:

Refs #26761 -- Removed extra space in admin change list result header.

comment:14 Changed 18 months ago by Mariusz Felisiak

Resolution: wontfix
Status: assignedclosed
Triage Stage: AcceptedUnreviewed

After reconsideration I think we shouldn't move it forward. First of all it's quite niche. Moreover adding title to the admin changelist headers only for callables will be really confusing. On the other hand using Field.help_text will cause many unexpected tooltips since it's used mainly for instructions of filling forms. title has also accessible concerns. In the end, this addition isn't worth the complexity.

comment:15 Changed 17 months ago by Derek Hohls

After a 4 year wait, this is a disappointing response. I think its a fairly generally useful feature (not "niche") that allows custom fields similar functionality to original ones and enhances the admin.

Was the proposed patch not able to pass the required tests?

comment:16 in reply to:  15 Changed 17 months ago by Mariusz Felisiak

Replying to Derek Hohls:

Was the proposed patch not able to pass the required tests?

It's not about tests, please take a look at my response.

comment:17 Changed 17 months ago by Carlton Gibson

Cc: Carlton Gibson added

comment:18 Changed 16 months ago by Hugo Osvaldo Barrera

I think this ticket somehow manages to mix up two very different requests into one:

  1. Add a help_text to methods:
from django.contrib import admin

class AuthorAdmin(admin.ModelAdmin):
    fields = ('name', 'date_of_birth', 'is_underage')

    def is_underage(self, obj):
        return obj.age < 18

    is_underage.help_text = 'Indicates if the author is under 18.'
  1. Show help_text as a title in changelistheaders.

As far as I understand the reason to reject this feature request are that this second feature seems to niche (note: I agree on that).

On the other hand, help_text for method-fields seem to make perfect sense. They would be rendered on the changeform just like the help_text for any other readonly field.

They also don't seem niche at all, and align very well with the existing admin UX.

Do you think just the first item would be acceptable? Looks like the implementation can be extracted from #12309, excluding the changelist changes.

comment:19 in reply to:  18 Changed 16 months ago by Mariusz Felisiak

Replying to Hugo Osvaldo Barrera:

On the other hand, help_text for method-fields seem to make perfect sense. They would be rendered on the changeform just like the help_text for any other readonly field.

They also don't seem niche at all, and align very well with the existing admin UX.

Do you think just the first item would be acceptable? Looks like the implementation can be extracted from #12309, excluding the changelist changes.

You can use short_description that already works for methods, that's more appropriate because you want to describe a value. help_text is rather an instruction for filling forms.

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