views:

126

answers:

2

Hi! I've this django form

class CustomerForm(forms.Form):
    first_name = forms.CharField(label=_('Nome'), max_length=30)
    last_name = forms.CharField(label=_('Cognome'), max_length=30)

    business_name = forms.CharField(label=_('Ragione Sociale'),
                                                               max_length=100)
    vat_number = forms.CharField(label=_('Partita iva'),
                                                max_length=11, required=False)

and I want to group the inputs (first_name and last_name, business_name and vat_number) so that when I display the form I get first_name and last_name in a div and business_name and vat_number in a another div

is this possible?

Thanks :)

A: 

There's nothing to stop you doing this in your template. Remember, as the documentation says, the {{ form.as_p }} etc are just shortcuts. As soon as you need to do something different, you can just fall back to iterating through the fields in your template, or even listing them individually.

Daniel Roseman
I know :) but I hope that soon there will be a simple method to group inputs in the form declaration.Anyway thanks for the reply ;)
patrick
+1  A: 

have a look at the Stacked/Grouped Forms snippet, where you can define "Stacks" (Groups) of fields in your Form.

Renaud