#36038: Added a test case for the display_for_field function when a FileField is
passed.
-------------------------------------+-------------------------------------
Reporter: Antoliny | Owner: (none)
Type: | Status: assigned
Cleanup/optimization |
Component: Utilities | Version: 5.1
Severity: Normal | Keywords: display_for_field,
Triage Stage: | FileFIeld
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
def display_for_field(value, field, empty_value_display):
from django.contrib.admin.templatetags.admin_list import _boolean_icon
...
elif isinstance(field, (models.IntegerField, models.FloatField)):
return formats.number_format(value)
elif isinstance(field, models.FileField) and value:
return format_html('<a href="{}">{}</a>', value.url, value)
...
}}}
There is no test case for the display_for_field function when a
`FileField` object is passed. -->
[
https://github.com/django/django/blob/main/tests/admin_utils/tests.py
admin_utils test code]
When the `FileField` handling was added in the above function, I found
that the test was conducted indirectly through the ModelAdmin
readonly_fields attribute. -->
[
https://github.com/django/django/blob/main/tests/admin_widgets/tests.py#L654
test code]
However, I believe it would be better to have a direct test case for when
a FileField is passed, considering that display_for_field function is
globally accessible.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36038>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.