On Friday, 20 July 2012 00:41:04 UTC-7, Alex Strickland wrote: > > Hi > > I am generating a page with a variable list of categories (shown in a > Bootstrap accordion control) displayed as checkboxes. So a user may > select any or all of the checkboxes to categorise an article. > > I did that just as a wireframe/demo. Trouble is I didn't think how that > might work with Django's form processing, as I now have a variable list > of form fields to deal with. > > Can it work with Django forms? Or should I go on my own way and analyse > the POST data to try and capture the selections and save them. > > I'm new at this so normal excuses for idiocy... > -- > Regards > Alex >
You don't want a variable number of fields, you just want a single MultipleChoiceField field using a CheckboxSelectMultiple widget. https://docs.djangoproject.com/en/1.4/ref/forms/fields/#multiplechoicefield https://docs.djangoproject.com/en/1.4/ref/forms/widgets/#checkboxselectmultiple -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zH1WoiVSf7oJ. 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.