1
0
mirror of https://github.com/django/django.git synced 2025-10-30 17:16:10 +00:00

[1.11.x] Fixed #28075 -- Prevented ChoiceWidget from localizing option values.

Backport of 581879a510 from master
This commit is contained in:
Jon Dufresne
2017-04-21 09:14:40 -07:00
committed by Tim Graham
parent c9d933ba99
commit 1442e29983
5 changed files with 97 additions and 1 deletions

View File

@@ -2,8 +2,10 @@
from __future__ import unicode_literals
import copy
import datetime
from django.forms import Select
from django.test import override_settings
from django.utils.safestring import mark_safe
from .base import WidgetTest
@@ -221,6 +223,34 @@ class SelectTest(WidgetTest):
</select>"""
))
@override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
def test_doesnt_localize_option_value(self):
choices = [
(1, 'One'),
(1000, 'One thousand'),
(1000000, 'One million'),
]
html = """
<select name="number">
<option value="1">One</option>
<option value="1000">One thousand</option>
<option value="1000000">One million</option>
</select>
"""
self.check_html(self.widget(choices=choices), 'number', None, html=html)
choices = [
(datetime.time(0, 0), 'midnight'),
(datetime.time(12, 0), 'noon'),
]
html = """
<select name="time">
<option value="00:00:00">midnight</option>
<option value="12:00:00">noon</option>
</select>
"""
self.check_html(self.widget(choices=choices), 'time', None, html=html)
def test_options(self):
options = list(self.widget(choices=self.beatles).options(
'name', ['J'], attrs={'class': 'super'},