summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-09-02 20:17:15 +0200
committerClaude Paroz <claude@2xlibre.net>2016-09-03 13:46:41 +0200
commit2ced2f785d5aca0354abf5841d5449b7a49509dc (patch)
tree46ade22a7c8d9ccdbab4a7fcb25f702172352521 /django/forms
parentb1d6b0a7b121eec860b518b4903d7c8c74f7773b (diff)
Replaced smart_* by force_* calls whenever possible
The smart_* version should only be used when a lazy string should keep its lazy status.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/boundfield.py8
-rw-r--r--django/forms/fields.py8
-rw-r--r--django/forms/models.py4
3 files changed, 9 insertions, 11 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
index e68744dbdc..b6be395a67 100644
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -5,9 +5,7 @@ import datetime
from django.forms.utils import flatatt, pretty_name
from django.forms.widgets import Textarea, TextInput
from django.utils import six
-from django.utils.encoding import (
- force_text, python_2_unicode_compatible, smart_text,
-)
+from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.functional import cached_property
from django.utils.html import conditional_escape, format_html, html_safe
from django.utils.safestring import mark_safe
@@ -196,8 +194,8 @@ class BoundField(object):
associated Form has specified auto_id. Returns an empty string otherwise.
"""
auto_id = self.form.auto_id
- if auto_id and '%s' in smart_text(auto_id):
- return smart_text(auto_id) % self.html_name
+ if auto_id and '%s' in force_text(auto_id):
+ return force_text(auto_id) % self.html_name
elif auto_id:
return self.html_name
return ''
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 45b425efd6..4a4b93b2b5 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -30,7 +30,7 @@ from django.forms.widgets import (
from django.utils import formats, six
from django.utils.dateparse import parse_duration
from django.utils.duration import duration_string
-from django.utils.encoding import force_str, force_text, smart_text
+from django.utils.encoding import force_str, force_text
from django.utils.ipv6 import clean_ipv6_address
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
@@ -349,7 +349,7 @@ class DecimalField(IntegerField):
return None
if self.localize:
value = formats.sanitize_separators(value)
- value = smart_text(value).strip()
+ value = force_text(value).strip()
try:
value = Decimal(value)
except DecimalException:
@@ -799,7 +799,7 @@ class ChoiceField(Field):
"Returns a Unicode object."
if value in self.empty_values:
return ''
- return smart_text(value)
+ return force_text(value)
def validate(self, value):
"""
@@ -868,7 +868,7 @@ class MultipleChoiceField(ChoiceField):
return []
elif not isinstance(value, (list, tuple)):
raise ValidationError(self.error_messages['invalid_list'], code='invalid_list')
- return [smart_text(val) for val in value]
+ return [force_text(val) for val in value]
def validate(self, value):
"""
diff --git a/django/forms/models.py b/django/forms/models.py
index ff6b2f0251..f44ce33f65 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -19,7 +19,7 @@ from django.forms.widgets import (
HiddenInput, MultipleHiddenInput, SelectMultiple,
)
from django.utils import six
-from django.utils.encoding import force_text, smart_text
+from django.utils.encoding import force_text
from django.utils.text import capfirst, get_text_list
from django.utils.translation import ugettext, ugettext_lazy as _
@@ -1186,7 +1186,7 @@ class ModelChoiceField(ChoiceField):
generate the labels for the choices presented by this object. Subclasses
can override this method to customize the display of the choices.
"""
- return smart_text(obj)
+ return force_text(obj)
def _get_choices(self):
# If self._choices is set, then somebody must have manually set