Hi everybody, I have a form with a field that uses the SelectMultiple
widget:

class DocumentForm(forms.ModelForm):
   options = forms.CharField(label='Options', max_length=100
,widget=forms.SelectMultiple(attrs={'class':'listbox'}, choices=([(aspect.id,
unicode(aspect.title)) for aspect in aspects ])) , required=False)

How you can see the field is populated automacally from a list: "choices =
([(aspect.id, unicode(aspect.title)) for aspect in aspects ]))", this works
wonderfull when I am inserting in the database the document model.

But when I want to make an update over the document object I use the same
form and I populated the form like this:

myform = DocumentForm(instance= document)

I want that the listbox displayed with all the options available an the ones
that are inserted in the database with the document mark as selected.
For instance if all the options available are A, B, C, D and the document I
want to update has only the option A and C, I want in the list box options
A, B , C ,  D but option A and C mark as selected.

Could you please help me do that ?
How would you do it ?

Thanks in advance.
Regards
Ariel

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