mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Refs #27795 -- Removed unneeded force_text calls
Thanks Tim Graham for the review.
This commit is contained in:
@@ -108,13 +108,12 @@ class BoundField:
|
||||
'It will be mandatory in Django 2.1.' % widget.__class__,
|
||||
RemovedInDjango21Warning, stacklevel=2,
|
||||
)
|
||||
html = widget.render(
|
||||
return widget.render(
|
||||
name=name,
|
||||
value=self.value(),
|
||||
attrs=attrs,
|
||||
**kwargs
|
||||
)
|
||||
return force_text(html)
|
||||
|
||||
def as_text(self, attrs=None, **kwargs):
|
||||
"""
|
||||
|
||||
@@ -225,14 +225,14 @@ class BaseForm:
|
||||
label = ''
|
||||
|
||||
if field.help_text:
|
||||
help_text = help_text_html % force_text(field.help_text)
|
||||
help_text = help_text_html % field.help_text
|
||||
else:
|
||||
help_text = ''
|
||||
|
||||
output.append(normal_row % {
|
||||
'errors': force_text(bf_errors),
|
||||
'label': force_text(label),
|
||||
'field': str(bf),
|
||||
'errors': bf_errors,
|
||||
'label': label,
|
||||
'field': bf,
|
||||
'help_text': help_text,
|
||||
'html_class_attr': html_class_attr,
|
||||
'css_classes': css_classes,
|
||||
@@ -240,7 +240,7 @@ class BaseForm:
|
||||
})
|
||||
|
||||
if top_errors:
|
||||
output.insert(0, error_row % force_text(top_errors))
|
||||
output.insert(0, error_row % top_errors)
|
||||
|
||||
if hidden_fields: # Insert any hidden fields in the last row.
|
||||
str_hidden = ''.join(hidden_fields)
|
||||
|
||||
@@ -4,7 +4,6 @@ from collections import UserList
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError # backwards compatibility
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.html import escape, format_html, format_html_join, html_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
@@ -60,7 +59,7 @@ class ErrorDict(dict):
|
||||
return ''
|
||||
return format_html(
|
||||
'<ul class="errorlist">{}</ul>',
|
||||
format_html_join('', '<li>{}{}</li>', ((k, force_text(v)) for k, v in self.items()))
|
||||
format_html_join('', '<li>{}{}</li>', self.items())
|
||||
)
|
||||
|
||||
def as_text(self):
|
||||
@@ -110,7 +109,7 @@ class ErrorList(UserList, list):
|
||||
return format_html(
|
||||
'<ul class="{}">{}</ul>',
|
||||
self.error_class,
|
||||
format_html_join('', '<li>{}</li>', ((force_text(e),) for e in self))
|
||||
format_html_join('', '<li>{}</li>', ((e,) for e in self))
|
||||
)
|
||||
|
||||
def as_text(self):
|
||||
@@ -132,7 +131,7 @@ class ErrorList(UserList, list):
|
||||
error = self.data[i]
|
||||
if isinstance(error, ValidationError):
|
||||
return list(error)[0]
|
||||
return force_text(error)
|
||||
return error
|
||||
|
||||
def __reduce_ex__(self, *args, **kwargs):
|
||||
# The `list` reduce function returns an iterator as the fourth element
|
||||
|
||||
Reference in New Issue
Block a user