mirror of https://github.com/django/django.git
Fixed #26173 -- Prevented localize_input() from formatting booleans as numbers.
This commit is contained in:
parent
bb51dc902d
commit
f7a9872b91
|
@ -214,6 +214,8 @@ def localize_input(value, default=None):
|
||||||
"""
|
"""
|
||||||
if isinstance(value, six.string_types): # Handle strings first for performance reasons.
|
if isinstance(value, six.string_types): # Handle strings first for performance reasons.
|
||||||
return value
|
return value
|
||||||
|
elif isinstance(value, bool): # Don't treat booleans as numbers.
|
||||||
|
return six.text_type(value)
|
||||||
elif isinstance(value, (decimal.Decimal, float) + six.integer_types):
|
elif isinstance(value, (decimal.Decimal, float) + six.integer_types):
|
||||||
return number_format(value)
|
return number_format(value)
|
||||||
elif isinstance(value, datetime.datetime):
|
elif isinstance(value, datetime.datetime):
|
||||||
|
|
|
@ -1117,6 +1117,10 @@ class FormattingTests(SimpleTestCase):
|
||||||
form6.as_ul()
|
form6.as_ul()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_localized_input_func(self):
|
||||||
|
with self.settings(USE_THOUSAND_SEPARATOR=True):
|
||||||
|
self.assertEqual(localize_input(True), 'True')
|
||||||
|
|
||||||
def test_sanitize_separators(self):
|
def test_sanitize_separators(self):
|
||||||
"""
|
"""
|
||||||
Tests django.utils.formats.sanitize_separators.
|
Tests django.utils.formats.sanitize_separators.
|
||||||
|
|
Loading…
Reference in New Issue