On Feb 10, 5:51 pm, Sergey Koval <serge.ko...@gmail.com> wrote: > On Tue, Feb 10, 2009 at 1:21 PM, Konstantin S <ktechli...@gmail.com> wrote: > > > Hello > > > I have a form created from forms.ModelForm and in my model one of the > > fields is m2m field. Now when form is displayed for that m2m filed I'd > > like to have something that looks like checkbox where user can select > > several alternatives. I know that I can use widgets here and there are > > some that can be used in my case, but I don't know how do I use them > > in case of form being generated as ModelForm ? > > If you want to show multiple checkboxes, use CheckboxSelectMultiple widget. > > Sample code: > > class MyForm(forms.ModelForm): > my_field = fields.ModelMultipleChoiceField(queryset=your_query_set, > widget=forms.CheckboxSelectMultiple) >
Thanks, that's exactly I was looking for. I didn't know that fields may be overwritten if the form is derived from a forms.ModelForm class --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---