I once saw something for this on djangosnippets.  Search hard.

On Fri, Apr 2, 2010 at 1:09 PM, ben <ben.k...@gmail.com> wrote:
> Hi, I am new to Django. I am currently using the latest Django 1.2
> from trunk. I am trying to store a list of values in a
> CommaSeperatedIntegerList. I would like to use a
> CheckboxSelectMultiple widget to render and select the values in the
> list. I have setup my code like so.
>
> SOME_CHOICES =  (('1', 'ch1'),('2', 'ch2'), ('3', 'ch3'),('4',"ch4"),
> ('5',"ch5"),)
>
> class QandA(models.Model):
>    q1 = models.CommaSeparatedIntegerField(choices=SOME_CHOICES,
> max_length=100, null=True,blank=True)
>
>
> class QandAForm(ModelForm):
>      class Meta:
>          model=QandA
>          fields=['q1']
>          widgets={'q1':forms.CheckboxSelectMultiple,}
>
> The form renders properly but I get the following validation error
> after posting.
>
> "Select a valid choice. [u'1'] is not one of the available choices."
>
> The same thing happens when I attempt to use SelectMultiple as the
> widget. Can anyone tell me what I am doing wrong? I have googled about
> but have not been able to find anything describing how to handle this.
>
> Thanks, Ben
>
> --
> 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.
>
>

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

Reply via email to