diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2012-07-05 23:23:03 +0100 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2012-07-06 00:23:02 +0100 |
| commit | 8fdc56d2a6f7537cdd52272501af9e94cab96ed4 (patch) | |
| tree | 0925e7ddfebdf04daab3cf4baf78b1136cbe4bbc | |
| parent | d3c2eb103f6682c029a850e60dc4cf85896b6aa2 (diff) | |
Fixed #18572 - Python26 string format incompatibility
Thanks to anonymous/AeroNotix for the report
| -rw-r--r-- | django/contrib/admin/templatetags/admin_list.py | 4 | ||||
| -rw-r--r-- | django/forms/forms.py | 2 | ||||
| -rw-r--r-- | django/forms/util.py | 8 | ||||
| -rw-r--r-- | django/forms/widgets.py | 12 | ||||
| -rw-r--r-- | django/template/defaulttags.py | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 29b5d71a16..0f15781fa9 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('<span class="this-page">{}</span> ', i+1) + return format_html('<span class="this-page">{0}</span> ', i+1) else: return format_html('<a href="{0}"{1}>{2}</a> ', 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 880873a273..7942275609 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 91a5686886..8cf03d38af 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('<ul class="errorlist">{}</ul>', + return format_html('<ul class="errorlist">{0}</ul>', format_html_join('', '<li>{0}{1}</li>', ((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('<ul class="errorlist">{}</ul>', - format_html_join('', '<li>{}</li>', + return format_html('<ul class="errorlist">{0}</ul>', + format_html_join('', '<li>{0}</li>', ((force_unicode(e),) for e in self) ) ) diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 65caa68db2..04a838093c 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('<input{} />', flatatt(final_attrs)) + return format_html('<input{0} />', 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('<input{} />', flatatt(input_attrs))) + inputs.append(format_html('<input{0} />', 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('<input{} />', flatatt(final_attrs)) + return format_html('<input{0} />', 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('<select{}>', flatatt(final_attrs))] + output = [format_html('<select{0}>', 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('<select multiple="multiple"{}>', flatatt(final_attrs))] + output = [format_html('<select multiple="multiple"{0}>', 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('<input{} />', flatatt(final_attrs)) + return format_html('<input{0} />', flatatt(final_attrs)) class RadioFieldRenderer(StrAndUnicode): """ diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index d27439b3b8..52d886a5a1 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("<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='{}' /></div>", csrf_token) + return format_html("<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='{0}' /></div>", csrf_token) else: # It's very probable that the token is missing because of # misconfiguration, so we raise a warning |
