Can you clarify what you mean by sequence. It would be appreciated if you can provide me of an example which might help me to understand how to implement it.
Thanks, Jeff On Fri, Jun 18, 2010 at 8:44 AM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > > > On 18 juin, 15:03, Jeff Green <jeffhg2...@gmail.com> wrote: > > I have been trying unsuccessfully to select the initial value of a > > multi select drop down. > > > > I was wondering what I am missing as to why this does not seem to be > > working. > > > > Here is a snippet of my code > > > > self.fields[config.ConfigurationName] = forms.MultipleChoiceField( > > choices=choicelist, > > initial='choice753', > > required=False) > > > > A MultipleChoiceField works with a sequence, not with a single > element, so passing the appropriate sequence as initial value might > help. > > self.fields[config.ConfigurationName] = forms.MultipleChoiceField( > choices=choicelist, > initial=['choice753'], # use > a list here > required=False) > > > > PS 1 : not tested but IIRC that's how I always initialised these > fields. > > PS 2 : In case you wonder why it didn't raise an exception with a > single string as initial value, remember that strings are sequences > too - so what the MultipleChoiceField tried to use was in fact ['c', > 'h', 'o', 'i', 'c', 'e', '7', '5', '3'] !-) > > HTH > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.