I have a problem setting the check boxes that are "checked" when my form returns (Please let me know if my logic is wrong from go)
My logic: -- After options are selected in my form, i save() the field[] in a textfield (concat string with commas) -- when textfield is returned, i split() the string back into an array and want to loop the MultipleChoiceField form field and set the ones that are checked. ########################## view ################################# if request.POST["action"] == "update": lookingfor = '' profile_form = ProfileForm(request.POST, instance=user.get_profile()) if profile_form.is_valid(): profile = profile_form.save(commit=False) for var in request.POST.getlist('lookingfor'): lookingfor += var + ',' profile.lookingfor = lookingfor profile.user = user profile.save() ################################ model ########################### lookingfor = models.TextField(_('Looking For'),null=True, blank=True) ################################ form ############################ LOOKING_FOR = ( ('Friendship', 'Friendship'), ('Dating', 'Dating'), ('A Relationship', 'A Relationship'), ('Networking', 'Networking'), ) class ProfileForm(forms.ModelForm): lookingfor = forms.MultipleChoiceField(required=False, label='Checklist', widget=forms.CheckboxSelectMultiple, choices=LOOKING_FOR) <--- (what will i set the "initial" parameter to? ) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---