On Fri, 23 Dec 2011 09:42:37 +0100, Mengu <whalb...@gmail.com> wrote:

you need to set "initial" attribute of TypedChoiceField.

Thanks, I knew about the initial only on form instance and not on field :)

On Dec 23, 10:34 am, Martin Tiršel <dja...@blackpage.eu> wrote:
Hello,

I have:

class SomeForm(forms.Form):
     ...

     def __init__(self, *args, **kwargs):
         ...
         super(SomeForm, self).__init__(*args, **kwargs)
         ...
         self.fields['starting_location'] = forms.TypedChoiceField(
             label=_('Starting location'),
             choices=DIRECTIONS_CHOICES,
             coerce=int
         )

Now I want to choose as initial selection one random item from
DIRECTIONS_CHOICES choices but I have to do it in this __init__() method
(not in view!). How can I achieve this?

Thanks,
Martin

--
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