'Django form: visibly group or separate fields
I have a form that I'm displaying within a Django app. This form has a number of fields.
To make the UI more intuitive, I would like to display the fields not simply one after the other, but instead grouped into sections - be it within a box or by separating the sections with a horizontal line or larger spacing or custom text etc.
My main interest is having the subgroups visibly separated from each other. Being able to use some text (basically a label without an attached field) as section devider would be a welcome bonus.
How can I achieve this?
Current example code:
forms.py:
from django import forms
class MyForm(forms.Form):
color1 = forms.CharField()
items_color1 = forms.CharField()
# some devider here
color2 = forms.CharField()
items_color2 = forms.CharField()
mypage.html:
<table>
{{ form.as_table }}
<tr>
<td> </td>
<td><input type="submit" value="Submit" id="form_field" name="submit_btn"></td>
</tr>
</table>
(I'm pretty new to Django. My previous GUI experience is mainly with PyQt5.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
