Multichoicefield with checkbox in django with Model forms -


i initializing model form in django , later adding multichoicefield choices displayed inline checkboxes being used update arrayfield on model.

model code:

class data(models.model):      my_array = arrayfield(models.charfield(max_length=100, blank=true), null=true) 

form code initialize multichoice field corresponding choices my_array:-

class dataform(modelform):     class meta:         model = models.data         fields = ('my_array')     my_choice = (('','none'), ('a','a'), ('b','b'), ('c','c'))     my_array = forms.multiplechoicefield(choices=my_choice , widget=forms.checkboxselectmultiple(), required=false) 

checked values saving correctly arrayfield 'my_array'. having problems retrieving these values on form.

i need multichoicefield have checked (selected) values based on saved model when retrieved filled out form. when model retrieved getting values corresponding my_array checkboxes not checked. seems definition of my_array on forms not using my_array field model prefill these checkboxes. idea on how done?

on careful observation noticed values on model saved [['a','b','c']] instead of ['a','b','c'] why while instantiating form model these not able select these values.

this happened because @ point converted my_array on model charfield arrayfield , correspondingly ran script on postgresql convert existing values.

i still not sure why of these converted values coming out comma delimited in single array object instead of being split multiple array objects. hope avoid running problem again , if find fix doing these conversions right way post here.