On May 25, 4:12 pm, Ndungi Kyalo <ndu...@gmail.com> wrote:
> Am trying to pre-select a radio button created with the django.forms library :
>
>     choices = forms.ChoiceField(
>         widget = forms.RadioSelect(),
>         choices = [
>             ['a', 'i liked it'],
>             ['b', 'i did not like it']
>         ],
>         required=True
>     )
>
> How would I go about getting the 'a' choice pre-selected on an unbound form ?

http://docs.djangoproject.com/en/1.3/ref/forms/api/#dynamic-initial-values

IIRC, this should be enough.

As a side note, you'd better use tuples than lists for your choices -
at least for the "value, label" pairs which are semantically tuples,
and possibly for the choices list itself but then it's more of a micro-
optimisation (tuples are lest costly than lists).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to