Hey Retro, I'm struggling with the same thing. I've found two interesting links which take two different approaches although I can't get either to quite work (I think the template is just not seeing the actual control but it's not complaining loudly). But it's quite possible that you'll be able to get it working: http://stackoverflow.com/questions/733880/iterate-over-choices-in-checkboxselectmultiple http://www.zoia.org/blog/2007/03/24/iterating-over-items-of-selection-fields-in-django-templates-using-newforms/
Please post if you find a solution and I will if I get it first :-) Cheers. On May 23, 9:48 pm, Retro486 <russell.bernha...@gmail.com> wrote: > I'm using the CheckboxSelectMultiple widget in a MultipleChoiceField > and I need more control over where the field labels go and the field > themselves. So far this is the only field type I've had a problem > with. I've spent at least a few hours trying to find info on the web > to no avail. > > I can't figure out how to iterate over the list of choices in my > template. Here's the snippet from my form object: > > USERTYPES = ( > ('f', 'Fan'), > ('b', 'Band'), > ('v', 'Venue'), > ) > usertype = forms.MultipleChoiceField(choices=USERTYPES, > widget=forms.CheckboxSelectMultiple()) > > And here's the snippet from my template (I know the attributes don't > exist; that's what my question is): > > {% for choice in form.usertype %} > <tr><td>{{ choice.label }}</td><td>{{ choice.field }}</td></tr> > {% endfor %} > > Any ideas? The rest of the form works perfectly so assume all other > variables are properly defined and are usable. > > Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---