summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-08-22 14:45:08 +0200
committerTim Graham <timograham@gmail.com>2017-08-22 08:45:08 -0400
commited77bea58274e11e5a9e4c8b9650f50deb8a2b26 (patch)
tree52b9ef33e778da64515646c352baf14324cd89b8
parent7bba82453ce142e170325c28e684aa7ee719a0b3 (diff)
Refs #28502 -- Complemented stringformat tuple handling/test.
An additional test and a code change were suggested in a late review.
-rw-r--r--django/template/defaultfilters.py4
-rw-r--r--docs/releases/1.11.5.txt2
-rw-r--r--tests/template_tests/filter_tests/test_stringformat.py1
3 files changed, 5 insertions, 2 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index a1b08e0921..b18b41c293 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -223,9 +223,9 @@ def stringformat(value, arg):
See https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting
for documentation of Python string formatting.
"""
+ if isinstance(value, tuple):
+ value = str(value)
try:
- if isinstance(value, tuple):
- return ('%' + str(arg)) % str(value)
return ("%" + str(arg)) % value
except (ValueError, TypeError):
return ""
diff --git a/docs/releases/1.11.5.txt b/docs/releases/1.11.5.txt
index 556cc73793..e7c6c91a5d 100644
--- a/docs/releases/1.11.5.txt
+++ b/docs/releases/1.11.5.txt
@@ -13,3 +13,5 @@ Bugfixes
in GEOS 3.6.2) (:ticket:`28441`).
* Fixed test database creation with ``cx_Oracle`` 6 (:ticket:`28498`).
+
+* Fixed select widget rendering when option values are tuples (:ticket:`28502`).
diff --git a/tests/template_tests/filter_tests/test_stringformat.py b/tests/template_tests/filter_tests/test_stringformat.py
index 8efa5e0599..62ee19aef8 100644
--- a/tests/template_tests/filter_tests/test_stringformat.py
+++ b/tests/template_tests/filter_tests/test_stringformat.py
@@ -39,3 +39,4 @@ class FunctionTests(SimpleTestCase):
self.assertEqual(stringformat(1, 'z'), '')
self.assertEqual(stringformat(object(), 'd'), '')
self.assertEqual(stringformat(None, 'd'), '')
+ self.assertEqual(stringformat((1, 2, 3), 'd'), '')