diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 29b5d71a161..0f15781fa94 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -31,7 +31,7 @@ def paginator_number(cl,i): if i == DOT: return '... ' elif i == cl.page_num: - return format_html('{} ', i+1) + return format_html('{0} ', i+1) else: return format_html('{2} ', cl.get_query_string({PAGE_VAR: i}), @@ -162,7 +162,7 @@ def result_headers(cl): "url_primary": cl.get_query_string({ORDER_VAR: '.'.join(o_list_primary)}), "url_remove": cl.get_query_string({ORDER_VAR: '.'.join(o_list_remove)}), "url_toggle": cl.get_query_string({ORDER_VAR: '.'.join(o_list_toggle)}), - "class_attrib": format_html(' class="{}"', ' '.join(th_classes)) + "class_attrib": format_html(' class="{0}"', ' '.join(th_classes)) if th_classes else '', } diff --git a/django/forms/forms.py b/django/forms/forms.py index 880873a273a..79422756098 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -167,7 +167,7 @@ class BaseForm(StrAndUnicode): # punctuation. if self.label_suffix: if label[-1] not in ':?.!': - label = format_html('{}{}', label, self.label_suffix) + label = format_html('{0}{1}', label, self.label_suffix) label = bf.label_tag(label) or '' else: label = '' diff --git a/django/forms/util.py b/django/forms/util.py index 91a5686886e..8cf03d38aff 100644 --- a/django/forms/util.py +++ b/django/forms/util.py @@ -20,7 +20,7 @@ def flatatt(attrs): The result is passed through 'mark_safe'. """ - return format_html_join('', ' {}="{}"', attrs.items()) + return format_html_join('', ' {0}="{1}"', attrs.items()) class ErrorDict(dict, StrAndUnicode): """ @@ -33,7 +33,7 @@ class ErrorDict(dict, StrAndUnicode): def as_ul(self): if not self: return '' - return format_html('', + return format_html('', format_html_join('', '
  • {0}{1}
  • ', ((k, force_unicode(v)) for k, v in self.items()) @@ -51,8 +51,8 @@ class ErrorList(list, StrAndUnicode): def as_ul(self): if not self: return '' - return format_html('', - format_html_join('', '
  • {}
  • ', + return format_html('', + format_html_join('', '
  • {0}
  • ', ((force_unicode(e),) for e in self) ) ) diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 65caa68db2d..04a838093c7 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -254,7 +254,7 @@ class Input(Widget): if value != '': # Only add the 'value' attribute if a value is non-empty. final_attrs['value'] = force_unicode(self._format_value(value)) - return format_html('', flatatt(final_attrs)) + return format_html('', flatatt(final_attrs)) class TextInput(Input): input_type = 'text' @@ -295,7 +295,7 @@ class MultipleHiddenInput(HiddenInput): # An ID attribute was given. Add a numeric index as a suffix # so that the inputs don't all have the same ID attribute. input_attrs['id'] = '%s_%s' % (id_, i) - inputs.append(format_html('', flatatt(input_attrs))) + inputs.append(format_html('', flatatt(input_attrs))) return mark_safe('\n'.join(inputs)) def value_from_datadict(self, data, files, name): @@ -512,7 +512,7 @@ class CheckboxInput(Widget): if not (value is True or value is False or value is None or value == ''): # Only add the 'value' attribute if a value is non-empty. final_attrs['value'] = force_unicode(value) - return format_html('', flatatt(final_attrs)) + return format_html('', flatatt(final_attrs)) def value_from_datadict(self, data, files, name): if name not in data: @@ -544,7 +544,7 @@ class Select(Widget): def render(self, name, value, attrs=None, choices=()): if value is None: value = '' final_attrs = self.build_attrs(attrs, name=name) - output = [format_html('', flatatt(final_attrs))] + output = [format_html('', flatatt(final_attrs))] options = self.render_options(choices, [value]) if options: output.append(options) @@ -620,7 +620,7 @@ class SelectMultiple(Select): def render(self, name, value, attrs=None, choices=()): if value is None: value = [] final_attrs = self.build_attrs(attrs, name=name) - output = [format_html('', flatatt(final_attrs))] options = self.render_options(choices, value) if options: output.append(options) @@ -679,7 +679,7 @@ class RadioInput(SubWidget): final_attrs = dict(self.attrs, type='radio', name=self.name, value=self.choice_value) if self.is_checked(): final_attrs['checked'] = 'checked' - return format_html('', flatatt(final_attrs)) + return format_html('', flatatt(final_attrs)) class RadioFieldRenderer(StrAndUnicode): """ diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index d27439b3b87..52d886a5a11 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -47,7 +47,7 @@ class CsrfTokenNode(Node): if csrf_token == 'NOTPROVIDED': return format_html("") else: - return format_html("
    ", csrf_token) + return format_html("
    ", csrf_token) else: # It's very probable that the token is missing because of # misconfiguration, so we raise a warning