[1.8.x] Refs #14497 -- Handled empty readonly admin FileFields
Backport of 07cfe1bd82
from master
This commit is contained in:
parent
e06971340d
commit
343c087533
|
@ -388,7 +388,7 @@ def display_for_field(value, field):
|
||||||
return formats.number_format(value, field.decimal_places)
|
return formats.number_format(value, field.decimal_places)
|
||||||
elif isinstance(field, models.FloatField):
|
elif isinstance(field, models.FloatField):
|
||||||
return formats.number_format(value)
|
return formats.number_format(value)
|
||||||
elif isinstance(field, models.FileField):
|
elif isinstance(field, models.FileField) and value:
|
||||||
return mark_safe('<a href="%s">%s</a>' % (
|
return mark_safe('<a href="%s">%s</a>' % (
|
||||||
conditional_escape(value.url),
|
conditional_escape(value.url),
|
||||||
conditional_escape(value),
|
conditional_escape(value),
|
||||||
|
|
|
@ -397,6 +397,12 @@ class AdminFileWidgetTests(DjangoTestCase):
|
||||||
'<input type="file" name="cover_art" id="id_cover_art" />',
|
'<input type="file" name="cover_art" id="id_cover_art" />',
|
||||||
html=True,
|
html=True,
|
||||||
)
|
)
|
||||||
|
response = self.client.get(reverse('admin:admin_widgets_album_add'))
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
'<p></p>',
|
||||||
|
html=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
@override_settings(ROOT_URLCONF='admin_widgets.urls')
|
||||||
|
|
Loading…
Reference in New Issue