diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 678b2eac7e..4ed9c67ff2 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -544,7 +544,7 @@ class Select(Widget): option_value = '' option_value = force_text(option_value) if option_value in selected_choices: - selected_html = mark_safe(' selected="selected"') + selected_html = mark_safe(' selected') if not self.allow_multiple_selected: # Only allow for a single selection. selected_choices.remove(option_value) diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt index 4b17754cde..75407ceed8 100644 --- a/docs/releases/1.11.txt +++ b/docs/releases/1.11.txt @@ -483,8 +483,9 @@ Miscellaneous argument. Remove it because it doesn't have an effect in older versions of Django as these fields alway strip whitespace. -* The ``checked`` attribute rendered by form widgets now uses HTML5 boolean - syntax rather than XHTML's ``checked='checked'``. +* The ``checked`` and ``selected`` attribute rendered by form widgets now uses + HTML5 boolean syntax rather than XHTML's ``checked='checked'`` and + ``selected='selected'``. * :meth:`RelatedManager.add() `, diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index 4b5d7f27ce..aabaec0713 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -771,7 +771,7 @@ with the ``Author`` model. It works just like a regular formset:: {% for tz in timezones %} - + {% endfor %} diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 5db4a34478..4ef0ae45a3 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -1910,7 +1910,7 @@ Here's example HTML template code: {% get_available_languages as LANGUAGES %} {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} - {% endfor %} diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index ef0e44029f..c4ef2b5114 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -3335,7 +3335,7 @@ class AdminActionsTest(TestCase): """ response = self.client.get(reverse('admin:admin_views_externalsubscriber_changelist')) self.assertContains(response, ''' self.assertHTMLEqual(str(f['name']), '') self.assertHTMLEqual(str(f['composers']), """""") def test_form_with_disabled_fields(self): @@ -1814,8 +1814,8 @@ Password: """ """
  • Username:
  • Password:
  • Options:
  • """ ) @@ -1858,8 +1858,8 @@ Options:
  • Options:
  • """ ) @@ -1888,8 +1888,8 @@ Password:
  • Password:
  • Options:
  • """ ) p = UserRegistration(initial={'username': initial_stephane, 'options': initial_options}, auto_id=False) @@ -1898,8 +1898,8 @@ Password: """
  • Username:
  • Password:
  • Options:
  • """ ) @@ -2319,39 +2319,39 @@ Password: p = Person({'name': 'Joe'}, auto_id=False) self.assertHTMLEqual(str(p['is_cool']), """""") p = Person({'name': 'Joe', 'is_cool': '1'}, auto_id=False) self.assertHTMLEqual(str(p['is_cool']), """""") p = Person({'name': 'Joe', 'is_cool': '2'}, auto_id=False) self.assertHTMLEqual(str(p['is_cool']), """""") p = Person({'name': 'Joe', 'is_cool': '3'}, auto_id=False) self.assertHTMLEqual(str(p['is_cool']), """""") p = Person({'name': 'Joe', 'is_cool': True}, auto_id=False) self.assertHTMLEqual(str(p['is_cool']), """""") p = Person({'name': 'Joe', 'is_cool': False}, auto_id=False) self.assertHTMLEqual(str(p['is_cool']), """""") def test_forms_with_file_fields(self): @@ -2715,7 +2715,7 @@ Good luck picking a username that doesn't already exist.

  • @@ -2731,7 +2731,7 @@ Good luck picking a username that doesn't already exist.

    @@ -2749,7 +2749,7 @@ Good luck picking a username that doesn't already exist.

    diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py index bc4aebd5c4..81a6feef2a 100644 --- a/tests/forms_tests/tests/tests.py +++ b/tests/forms_tests/tests/tests.py @@ -110,24 +110,24 @@ class ModelFormCallableModelDefault(TestCase): self.assertHTMLEqual( ChoiceFieldForm().as_p(), """

    """ @@ -147,26 +147,26 @@ class ModelFormCallableModelDefault(TestCase): }).as_p(), """

    """ ) @@ -310,7 +310,7 @@ class EmptyLabelTestCase(TestCase): f.as_p(), """

    """ @@ -323,7 +323,7 @@ class EmptyLabelTestCase(TestCase): """

    """ @@ -353,7 +353,7 @@ class EmptyLabelTestCase(TestCase): """

    """ @@ -373,7 +373,7 @@ class EmptyLabelTestCase(TestCase):

    """ @@ -388,7 +388,7 @@ class EmptyLabelTestCase(TestCase):

    """ ) diff --git a/tests/forms_tests/widget_tests/test_multiwidget.py b/tests/forms_tests/widget_tests/test_multiwidget.py index bb6f8bfc4f..5338104f5c 100644 --- a/tests/forms_tests/widget_tests/test_multiwidget.py +++ b/tests/forms_tests/widget_tests/test_multiwidget.py @@ -141,8 +141,8 @@ class MultiWidgetTest(WidgetTest): """ diff --git a/tests/forms_tests/widget_tests/test_nullbooleanselect.py b/tests/forms_tests/widget_tests/test_nullbooleanselect.py index 42b1dbf7c1..b9d55200c5 100644 --- a/tests/forms_tests/widget_tests/test_nullbooleanselect.py +++ b/tests/forms_tests/widget_tests/test_nullbooleanselect.py @@ -12,7 +12,7 @@ class NullBooleanSelectTest(WidgetTest): self.check_html(self.widget, 'is_cool', True, html=( """""" )) @@ -22,14 +22,14 @@ class NullBooleanSelectTest(WidgetTest): """""" )) def test_render_none(self): self.check_html(self.widget, 'is_cool', None, html=( """""" @@ -39,7 +39,7 @@ class NullBooleanSelectTest(WidgetTest): self.check_html(self.widget, 'is_cool', '2', html=( """""" )) @@ -57,7 +57,7 @@ class NullBooleanSelectTest(WidgetTest): """ """ diff --git a/tests/forms_tests/widget_tests/test_select.py b/tests/forms_tests/widget_tests/test_select.py index 185352cda3..dde84c476f 100644 --- a/tests/forms_tests/widget_tests/test_select.py +++ b/tests/forms_tests/widget_tests/test_select.py @@ -19,7 +19,7 @@ class SelectTest(WidgetTest): def test_render(self): self.check_html(self.widget(choices=self.beatles), 'beatle', 'J', html=( """ - + @@ -80,7 +80,7 @@ class SelectTest(WidgetTest): self.check_html(widget, 'num', 2, html=( """""" )) @@ -95,7 +95,7 @@ class SelectTest(WidgetTest): html=( """""" ), @@ -106,7 +106,7 @@ class SelectTest(WidgetTest): html=( """""" ), @@ -117,7 +117,7 @@ class SelectTest(WidgetTest): html=( """""" ), @@ -128,7 +128,7 @@ class SelectTest(WidgetTest): self.check_html(widget, 'num', 2, html=( """""" )) @@ -147,7 +147,7 @@ class SelectTest(WidgetTest): """""" @@ -157,7 +157,7 @@ class SelectTest(WidgetTest): - + """ )) @@ -177,7 +177,7 @@ class SelectTest(WidgetTest): 'email', 'ŠĐĆŽćžšđ', html=( """ - + @@ -215,7 +215,7 @@ class SelectTest(WidgetTest): """""" diff --git a/tests/forms_tests/widget_tests/test_selectdatewidget.py b/tests/forms_tests/widget_tests/test_selectdatewidget.py index 6efa240b66..b155c946e6 100644 --- a/tests/forms_tests/widget_tests/test_selectdatewidget.py +++ b/tests/forms_tests/widget_tests/test_selectdatewidget.py @@ -101,7 +101,7 @@ class SelectDateWidgetTest(WidgetTest): - + @@ -128,7 +128,7 @@ class SelectDateWidgetTest(WidgetTest): - + @@ -152,7 +152,7 @@ class SelectDateWidgetTest(WidgetTest): - + @@ -178,7 +178,7 @@ class SelectDateWidgetTest(WidgetTest): - + @@ -20,8 +20,8 @@ class SelectMultipleTest(WidgetTest): def test_render_multiple_selected(self): self.check_html(self.widget(choices=self.beatles), 'beatles', ['J', 'P'], html=( """""" @@ -60,11 +60,11 @@ class SelectMultipleTest(WidgetTest): """ self.check_html(self.widget(choices=self.numeric_choices), 'choices', ['0'], html=( """""" )) @@ -75,9 +75,9 @@ class SelectMultipleTest(WidgetTest): """ self.check_html(self.widget(choices=self.beatles), 'beatles', ['J', 'G', 'foo'], html=( """""" )) @@ -88,7 +88,7 @@ class SelectMultipleTest(WidgetTest): self.check_html(self.widget(choices=choices), 'nums', [2], html=( """""" )) @@ -96,7 +96,7 @@ class SelectMultipleTest(WidgetTest): self.check_html(self.widget(choices=choices), 'nums', ['2'], html=( """""" )) @@ -104,7 +104,7 @@ class SelectMultipleTest(WidgetTest): self.check_html(self.widget(choices=choices), 'nums', [2], html=( """""" )) @@ -116,10 +116,10 @@ class SelectMultipleTest(WidgetTest): )) self.check_html(widget, 'nestchoice', ['outer1', 'inner2'], html=( """""" )) diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 5a05d16082..717150de0d 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -664,7 +664,7 @@ class FormattingTests(SimpleTestCase): '' '' '' - '' + '' '' '' '' '' '' '' '' '' '
  • Pub date:
  • Writer:
  • Article:
  • Categories:
  • Status: - +
  • Article:
  • Categories:
  • Status:
  • """ % (self.c1.pk, self.c2.pk, self.c3.pk)) @@ -1233,7 +1233,7 @@ class ModelFormBasicTests(TestCase): Slug: Pub date: Writer: @@ -1244,7 +1244,7 @@ class ModelFormBasicTests(TestCase): Status: - +
  • Article:
  • Categories:
  • Status:
  • Pub date:
  • Writer:
  • @@ -1420,7 +1420,7 @@ class ModelFormBasicTests(TestCase):
  • Status:
  • Pub date:
  • Writer:
  • Status: - +

    @@ -1933,7 +1933,7 @@ class ModelOneToOneFieldTests(TestCase): form.as_p(), '''

    @@ -2493,7 +2493,7 @@ class OtherModelFormTests(TestCase): form = InventoryForm(instance=core) self.assertHTMLEqual(six.text_type(form['parent']), '''''') @@ -2576,13 +2576,13 @@ class OtherModelFormTests(TestCase):

    + """.format(today_str) ) diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py index 60acc463cc..43a5b9526e 100644 --- a/tests/model_formsets/tests.py +++ b/tests/model_formsets/tests.py @@ -1134,7 +1134,7 @@ class ModelFormsetTest(TestCase): formset.forms[0].as_p(), '

    ' '

    ' diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index d375090151..e00b69b586 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -360,7 +360,7 @@ class ModelAdminTests(TestCase): str(form["main_band"]), '' % (band2.id, self.band.id) @@ -381,7 +381,7 @@ class ModelAdminTests(TestCase): str(form["main_band"]), '' % self.band.id )