On Tue, 2009-01-13 at 02:12 -0800, Thierry wrote:
> This doesn't seem to work:
> auto_open_choices = forms.MultipleChoiceField(choices=( ('google',
> 'Google'), ('msn', 'MSN'), ('yahoo', 'Yahoo')), required=False,
> initial=['google'])
>
> From what i read in the discussions here it should...
> What am i doing wrong?
Could you clarify what "doesn't deem to work" means in your case? If I
type this into a file:
from django import forms
class MyForm(forms.Form):
auto_open_choices = forms.MultipleChoiceField(choices=(
('google', 'Google'), ('msn', 'MSN'), ('yahoo',
'Yahoo')),
required=False, initial=['google'])
and try this at the "./manage.py shell" interactive prompt (which is the
same as using the form in a template), it has the "google" choice
selected in the initial form display.
In [1]: import sample
In [2]: print sample.MyForm()
<tr><th><label for="id_auto_open_choices">Auto open
choices:</label></th><td><select multiple="multiple" name="auto_open_choices"
id="id_auto_open_choices">
<option value="google" selected="selected">Google</option>
<option value="msn">MSN</option>
<option value="yahoo">Yahoo</option>
</select></td></tr>
So you've either trimmed a critical piece of code that is causing the
problem, or you have different expectations from what is intended to
happen.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---