Add Links for ImageField and FileField in admin_list.py
|Reported by:||Owned by:||nobody|
|Cc:||toke-django@…||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When I added ImageField or FileField to list_display_links, the result was not what I expected.
I saw the code in admin_list.py, the function items_for_result, there was no check for ImageField and FileFiled, I suggested to add following snippts:
# Line 176 elif isinstance(f, models.ImageField) or isinstance(f, models.FileField): if field_val is not None: result_repr = ('<a href="%s %s">%s</a>' % (settings.MEDIA_URL, field_val, field_val)) else: result_repr = EMPTY_CHANGELIST_VALUE
I hope the django team can consider about that.
Thanks in advance.
Change History (5)
comment:1 Changed 9 years ago by
|Component:||Contrib apps → Admin interface|
|Triage Stage:||Unreviewed → Design decision needed|