Say I have a form with 20 fields, and I want to put 10 of these fields (group1) in a particular div environment and the other 10 fields (group2) in a different div environme
I finally was able to bring @Yuji'Tomita'Tomitas regroup-template-tag-solution to work (see comments in @Yuji'Tomita'Tomitas answer to understand difficulties). I think this is really a nice and easy way to perfom grouping of fields!
The solution was to regroup via group
attribute of field accessing the field
attribute of returned BoundFields
. Minimal example:
In forms.py :
class TestForm(Form):
a = IntegerField()
a.group = 1
b = IntegerField()
b.group = 1
c = IntegerField()
c.group = 2
d = IntegerField()
d.group = 2
In template: