I have a form like the following:
class MyForm(Form):
#personal data
firstname = CharField()
lastname = CharField()
#education data
university = Char
One way to do this without displaying your form in the template using form.as_ul, is with django-uni-form. First you'll have to download it here and install it. Then the code for setting up your form could looks something like this:
from uni_form.helpers import FormHelper, Submit, Layout, Fieldset
class MyForm(Form):
#personal data
firstname = CharField()
lastname = CharField()
#education data
university = CharField()
major = CharField()
#foobar data
foobar = ChoiceField()
# now attach a uni_form helper to display the form
helper = FormHelper()
# create the layout
layout = Layout(
# first fieldset
Fieldset("Here you enter your personal data...",
'firstname', 'lastname'),
Fieldset("Here you enter your education data...",
'university', 'major'),
Fieldset('foobar')
# and add a submit button
sumbit = Submit('add', 'Submit information')
helper.add_input(submit)
Now, to display this in your template you would do this:
{% load uni_form %}
{% with form.helper as helper %}
{% uni_form form helper %}
{% endwith %}
This would output HTML (roughly) like this:
For more info on uni_form, read their docs (see the link above).
PS: I realize this reply is late, and I'm sure you already solved this problem, but I think this should be helpful for anyone just coming across this now.