On 3/29/06, Jiri Barton <[EMAIL PROTECTED]> wrote: > > Hello there, > > I want to display a checklist dynamically: > > 1 apple [ ] > 3 pears [ ] > 8 plums [ ] > > ([ ] stands for checkboxes) > > The items are generated on the fly. I can create the form fields in a > manipulator __init__ dynamically, such as in: > > for item in items: > self.fields.append(CheckboxField(fieldname="%s-%s" % (item.name, > item.number))) > > Then, in the template: > > {% for row in form %} > <tr><td>{{ row }}</td></tr> > {% endfor %} > > This does not work because ``form`` is not a a list. How could I solve > this? >
use form.fields > Then, I need to be able to display the labels next to the checkboxes. > But I cannot include them in self.fields because they are just texts. > How can I do it? I mean, do I need to create my own LabelField? > > Thank you in advance. for item in items: f = CheckboxField(fieldname="%s-%s" % (item.name,item.number)) #then add a lable f.label = something self.fields.append(f) -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---