File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
django/contrib/admin/templates/admin/widgets Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
{% if is_initial %}< p class ="file-upload "> {{ initial_text }}: < a href ="{{ widget.value.url }} "> {{ widget.value }}</ a > {% if not widget.required %}
2
2
< span class ="clearable-file-input ">
3
3
< input type ="checkbox " name ="{{ checkbox_name }} " id ="{{ checkbox_id }} " />
4
- < label for ="{{ checkbox_id }} "> {{ clear_checkbox_label }}</ label > {% endif %}</ span > < br />
4
+ < label for ="{{ checkbox_id }} "> {{ clear_checkbox_label }}</ label > </ span > {% endif %}< br />
5
5
{{ input_text }}:{% endif %}
6
6
< input type ="{{ widget.type }} " name ="{{ widget.name }} "{% include "django/forms/widgets/attrs.html" %} /> {% if is_initial %}</ p > {% endif %}
Original file line number Diff line number Diff line change @@ -21,3 +21,5 @@ Bugfixes
21
21
22
22
* Fixed admin's ``FieldListFilter.get_queryset()`` crash on invalid input
23
23
(:ticket:`28202`).
24
+
25
+ * Fixed invalid HTML for a required ``AdminFileWidget`` (:ticket:`28278`).
Original file line number Diff line number Diff line change @@ -434,6 +434,18 @@ def test_render(self):
434
434
'<input type="file" name="test" />' ,
435
435
)
436
436
437
+ def test_render_required (self ):
438
+ widget = widgets .AdminFileWidget ()
439
+ widget .is_required = True
440
+ self .assertHTMLEqual (
441
+ widget .render ('test' , self .album .cover_art ),
442
+ '<p class="file-upload">Currently: <a href="%(STORAGE_URL)salbums/'
443
+ r'hybrid_theory.jpg">albums\hybrid_theory.jpg</a><br />'
444
+ 'Change: <input type="file" name="test" /></p>' % {
445
+ 'STORAGE_URL' : default_storage .url ('' ),
446
+ },
447
+ )
448
+
437
449
def test_readonly_fields (self ):
438
450
"""
439
451
File widgets should render as a link when they're marked "read only."
You can’t perform that action at this time.
0 commit comments