[Django] #26761: Admin - add 'help_text' property to custom fields

78 views
Skip to first unread message

Django

unread,
Jun 15, 2016, 3:32:54 AM6/15/16
to django-...@googlegroups.com
#26761: Admin - add 'help_text' property to custom fields
-------------------------------+--------------------
Reporter: gamesbook | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Keywords: admin
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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.short_name = 'birth_date'
view_birth_date.empty_value_display = '???'
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.

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

Django

unread,
Jun 15, 2016, 8:28:24 AM6/15/16
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------

Reporter: gamesbook | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* keywords: admin =>
* needs_docs: => 0
* stage: Unreviewed => Accepted


Old description:

> 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.short_name = 'birth_date'
> view_birth_date.empty_value_display = '???'
> 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.

New description:

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.

--

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

Django

unread,
Jul 2, 2016, 10:24:10 AM7/2/16
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: gamesbook | Owner: ducdetronquito
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by ducdetronquito):

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


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

Django

unread,
Jul 3, 2016, 3:55:24 PM7/3/16
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: gamesbook | Owner: ducdetronquito
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (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 :)

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

Django

unread,
Jul 5, 2016, 11:12:35 AM7/5/16
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: gamesbook | Owner: ducdetronquito
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1


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

Django

unread,
Jul 5, 2016, 4:24:02 PM7/5/16
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: gamesbook | Owner: ducdetronquito
Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (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 !

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

Django

unread,
Sep 27, 2016, 8:10:07 PM9/27/16
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: ducdetronquito

Type: New feature | Status: assigned
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


Comment:

I left some ideas for improvement on the PR.

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

Django

unread,
Nov 16, 2018, 1:09:34 PM11/16/18
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+----------------------------------------
Reporter: Derek Hohls | Owner: Guille López

Type: New feature | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by Guille López):

* owner: ducdetronquito => Guille López
* version: 1.9 => master


Comment:

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.

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

Django

unread,
Nov 16, 2018, 1:10:36 PM11/16/18
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+----------------------------------------
Reporter: Derek Hohls | Owner: Guille López
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+----------------------------------------
Changes (by Guille López):

* cc: Guille López (added)


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

Django

unread,
Jan 12, 2020, 9:50:05 AM1/12/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani

Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by Hasan Ramezani):

* owner: Guille López => Hasan Ramezani


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

Django

unread,
Jan 12, 2020, 11:31:31 AM1/12/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 1 => 0


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

Django

unread,
Jun 17, 2020, 3:47:33 AM6/17/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1

* needs_tests: 0 => 1


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

Django

unread,
Jun 18, 2020, 3:45:30 AM6/18/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 1 => 0

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:12>

Django

unread,
Jun 25, 2020, 12:57:18 AM6/25/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"fbe82f82555bc25dccb476c749ca062f0b522be3" fbe82f82]:
{{{
#!CommitTicketReference repository=""
revision="fbe82f82555bc25dccb476c749ca062f0b522be3"
Refs #26761 -- Removed extra space in admin change list result header.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:13>

Django

unread,
Jun 25, 2020, 4:44:45 AM6/25/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by felixxm):

* status: assigned => closed
* resolution: => wontfix
* stage: Accepted => Unreviewed


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:14>

Django

unread,
Jul 1, 2020, 8:01:23 AM7/1/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (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?

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:15>

Django

unread,
Jul 1, 2020, 8:11:49 AM7/1/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (by felixxm):

Replying to [comment:15 Derek Hohls]:


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

It's not about tests, please take a look at my
[https://code.djangoproject.com/ticket/26761?replyto=15#comment:14
response].

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:16>

Django

unread,
Jul 2, 2020, 6:06:01 AM7/2/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by Carlton Gibson):

* cc: Carlton Gibson (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:17>

Django

unread,
Jul 30, 2020, 6:37:33 AM7/30/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (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.'
}}}

2. Show `help_text` as a `title` in `changelist`headers.

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:18>

Django

unread,
Jul 30, 2020, 7:23:32 AM7/30/20
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (by felixxm):

Replying to [comment:18 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:19>

Django

unread,
May 10, 2023, 5:05:27 AM5/10/23
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: dev

Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------
Changes (by Carsten Fuchs):

* cc: Carsten Fuchs (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:20>

Django

unread,
May 12, 2023, 9:49:07 AM5/12/23
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (by Adam Johnson):

Carsten [https://groups.google.com/d/msgid/django-developers/8e72c318
-f28d-465f-8707-47e77a5d0d20%40cafu.de wrote to the mailing list] asking
the ticket to be reconsidered. This is my reply.

It’s already possible to return arbitrary rendered HTML for fields, so one
can add "help text" that way. For example, using the internal "boolean
icon" display from the admin and adding a paragraph of text below
(untested!):

{{{
from django.contrib import admin
from django.contrib.admin.templatetags.admin_list import _boolean_icon
from django.utils.html import format_html


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

def is_underage(self, obj):
return format_html(
"{}<br><p>{}</p>",
_boolean_icon(obj.age < 18),
"Indicates if the author is under 18.",
)
}}}

So I would be against making any change because complete customization is
already possible. If you want terser syntax you can write a project-
specific decorator that fits your needs.

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:21>

Django

unread,
May 12, 2023, 10:42:30 AM5/12/23
to django-...@googlegroups.com
#26761: Add 'help_text' property to methods in ModelAdmin.list_display
-------------------------------+------------------------------------------
Reporter: Derek Hohls | Owner: Hasan Ramezani
Type: New feature | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------------

Comment (by Carsten Fuchs):

Hello Adam, thanks for your reply!

I understand how this approach solves the problem, however it makes it
difficult to achieve visual consistency with the genuine `help_text`
attributes, because for that the Admin's HTML markup and styling must
carefully be accounted for and be reproduced in `format_html("…")`. It
also doesn't cover the double-use of the `help_text` in the tooltips in
the table column headers on the list pages.

Using `format_html()` as you suggested properly covers my use case. I also
understand that new features cannot be added lightheartedly to the Admin.
However, it still feels to me that this is a (albeit small) piece of
functionality that is missing.

--
Ticket URL: <https://code.djangoproject.com/ticket/26761#comment:22>

Reply all
Reply to author
Forward
0 new messages