wildDAlex
wildDAlex

Reputation: 387

selected value in Django forms.ChoiceField

Here i have the form

vote = forms.ChoiceField(widget=forms.Select(), choices=(('1', '1',), ('2', '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?

Upvotes: 0

Views: 2231

Answers (1)

Brandon Taylor
Brandon Taylor

Reputation: 34593

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/

Upvotes: 2

Related Questions