1
0
mirror of https://github.com/django/django.git synced 2025-10-25 14:46:09 +00:00

[1.11.x] Fixed #28278 -- Fixed invalid HTML for a required AdminFileWidget.

Backport of 525dc283a6 from master
This commit is contained in:
kakulukia
2017-06-05 22:17:10 +02:00
committed by Tim Graham
parent 6ae60295d7
commit 992f143bad
3 changed files with 15 additions and 1 deletions

View File

@@ -434,6 +434,18 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
'<input type="file" name="test" />',
)
def test_render_required(self):
widget = widgets.AdminFileWidget()
widget.is_required = True
self.assertHTMLEqual(
widget.render('test', self.album.cover_art),
'<p class="file-upload">Currently: <a href="%(STORAGE_URL)salbums/'
r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a><br />'
'Change: <input type="file" name="test" /></p>' % {
'STORAGE_URL': default_storage.url(''),
},
)
def test_readonly_fields(self):
"""
File widgets should render as a link when they're marked "read only."