Django How to work with MultipleChoiceField -



Django How to work with MultipleChoiceField -

form.py:

checkbox_choices = ( ('value1','value1'), ('value2','value2'), ) class editprofileform(modelform): involvement = forms.multiplechoicefield(required=false, widget=checkboxselectmultiple(), choices=checkbox_choices,) def save(self, *args, **kwargs): u = self.instance.user u.interest = self.cleaned_data['interest'] u.save() profile = super(editprofileform, self).save(*args,**kwargs) homecoming profile

it saves in db [u'value1', u'value2']

now, how can render in template show string value1, value2 without [u' '] or there improve way save value string?

u.interest = u','.join(self.cleaned_data['interest'])

django

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -