#34241: Django admin not showing seconds for list_display nor readonly
DateTimeField
-------------------------------+--------------------------------------
     Reporter:  Petr DlouhĂ˝    |                    Owner:  nobody
         Type:  New feature    |                   Status:  closed
    Component:  contrib.admin  |                  Version:  4.1
     Severity:  Normal         |               Resolution:  wontfix
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  1
-------------------------------+--------------------------------------

Comment (by Petr DlouhĂ˝):

 OK. For anyone concerned I have find solution that is a bit hacky, but is
 best of what I can think is possible right now:

 In some `__init__.py` file:
 {{{
 from django.contrib.admin import utils
 from django.db.models import DateTimeField
 from django.utils.html import format_html


 _display_for_field = utils.display_for_field


 # Modify DateTime field format and display tooltip with full date and time
 def display_for_field(value, field, empty_value_display):
     if value and isinstance(field, DateTimeField):
         return format_html(
             '<span title="{}">{}</span>', value, value.strftime("%Y-%m-%d
 %H:%M:%S %Z")
         )
     return _display_for_field(value, field, empty_value_display)


 utils.display_for_field = display_for_field
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34241#comment:7>
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/01070185875800ce-19a5320b-33b3-4463-960a-4bf01563bf21-000000%40eu-central-1.amazonses.com.

Reply via email to