#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701881038e37a-35a8eb16-feb7-4917-b13d-d3e80b6e0ffa-000000%40eu-central-1.amazonses.com.

Reply via email to