Opened 9 years ago
Closed 9 years ago
#26582 closed Cleanup/optimization (fixed)
Better ArrayField/list formatting in the admin
Reported by: | Dan Watson | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When specifying an ArrayField in list_display or readonly_fields, the admin shows a rather ugly python representation of the list, e.g.:
[u'Value 1', u'Value 2', u'Value 3']
A simple solution would be to check for isinstance(value, (list, tuple))
in django.contrib.admin.utils.display_for_value
and return a comma- or semicolon-separated display string, then change django.contrib.admin.utils.display_for_field
to call display_for_value
at the end instead of just smart_text
. This would be pretty un-intrusive, and work for any fields providing list type values.
A more thorough solution might involve some mechanism by which fields or ModelAdmin
instances can customize the display formatting of field values. Or maybe even some sort of template-based rendering solution in line with https://github.com/django/django/pull/6498.
Change History (4)
comment:1 by , 9 years ago
Has patch: | set |
---|
comment:2 by , 9 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
https://github.com/django/django/pull/6558