1

Django 1.4.3 を使用して Web サイトを作成しています。同じ場所の選択(国、地域、都市)を持つ2つのフォームがあったので、使用してhtml IDを変更しました

country_id = forms.ChoiceField(choices=COUNTRY_CHOICES, required=False, label=u'Country', widget=forms.Select(attrs={'id': 'id_select_country_id'}))

フォームにはラベルがありますが、 http: //validator.w3.org/checkで HTML を検証すると、次のエラーが発生しました。

The for attribute of the label element must refer to a form control.
<label class="control-label" for="id_settings-country_id">Country</label>
<select id="id_select_country_id" name="settings-country_id">
....

html 選択の ID と一致するようにラベルの for 属性を変更するにはどうすればよいですか?

フォームの HTML 要素は、

{{ settings_form|as_bootstrap:"horizontal" }}

django-bootstrap-toolkit バージョン 2.15.0 を使用してフォームをレンダリングしています。

4

0 に答える 0