开发者

selected value in Django forms.ChoiceField

开发者 https://www.devze.com 2023-03-18 02:13 出处:网络
Here i have the form vote = forms.ChoiceField(widget=forms.Select(), choices=((\'1\', \'1\',), (\'2\',开发者_Go百科 \'2\',), (\'3\', \'3\',)), initial=\'2\')

Here i have the form

vote = forms.ChoiceField(widget=forms.Select(), choices=(('1', '1',), ('2',开发者_Go百科 '2',), ('3', '3',)), initial='2')

Django1.3 create from it the code

<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>

This selected-tag does not work. Should be

<option value="2" selected>2</option>

What am I doing wrong?


Occasionally, I've seen browsers not select the appropriate option, even with selected="selected" when doing an F5 or Command + R (on Mac). However, doing a full refresh of the page (Ctrl + F5) in FF on Windows, or reloading the url from the address bar, will correctly select the selected option. FireFox does sometimes behave this way: http://www.beyondcoding.com/2008/12/16/option-selectedselected-not-working/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号