#30577: feature request: custom rendering for readonly fields in admin -------------------------------+-------------------------------------- Reporter: David | Owner: nobody Type: New feature | Status: new Component: contrib.admin | Version: 5.1 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------------------------- Changes (by ldeluigi):
* cc: ldeluigi (added) * resolution: needsinfo => * status: closed => new * version: 2.2 => 5.1 Comment: I'd like to reopen this ticket in favor of another use case scenario: I have plenty of models that each have many DateTimeFields that are read only, namely 'updated' and 'created' timestamps. I want to customize how datetimes are displayed as HTML when they are read_only, but unfortunately Django admin invokes the hardcoded display functions to display read_only fields that don't have a widget set with read_only=True. I don't want to customize it once for each of these fields, I'd like to make a common abstract class that inherits from ModelAdmin once for all my forms and have it change the generated HTML for datetimefields for every subclass. Using formfield_overrides with a widget with read_only=True isn't enough because the AdminReadonlyField contents method wants the field to be explicitly listed in the form fields before checking if read_only is True on the widget. I'd like to be able to provide a read only representation of field classes from a ModelAdmin superclass. -- Ticket URL: <https://code.djangoproject.com/ticket/30577#comment:6> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018fe3ed5dc0-6e8f5421-8f6a-4525-ac4f-413bec282678-000000%40eu-central-1.amazonses.com.