Code

Ticket #19464: url_markup_template.diff

File url_markup_template.diff, 1.0 KB (added by rubyruy, 17 months ago)
Line 
1diff --git a/django/forms/widgets.py b/django/forms/widgets.py
2index c761ea8..19a7b65 100644
3--- a/django/forms/widgets.py
4+++ b/django/forms/widgets.py
5@@ -340,6 +340,8 @@ class ClearableFileInput(FileInput):
6     template_with_initial = '%(initial_text)s: %(initial)s %(clear_template)s<br />%(input_text)s: %(input)s'
7
8     template_with_clear = '%(clear)s <label for="%(clear_checkbox_id)s">%(clear_checkbox_label)s</label>'
9+
10+    url_markup_template = '<a href="{0}">{1}</a>'
11
12     def clear_checkbox_name(self, name):
13         """
14@@ -366,7 +368,7 @@ def render(self, name, value, attrs=None):
15
16         if value and hasattr(value, "url"):
17             template = self.template_with_initial
18-            substitutions['initial'] = format_html('<a href="{0}">{1}</a>',
19+            substitutions['initial'] = format_html(self.url_markup_template,
20                                                    value.url,
21                                                    force_text(value))
22             if not self.is_required: