Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django form as_table new row

I'm creating a table from a form:

<form method="post" action=".">{% csrf_token %}
    {{ form.as_table }}
    <input type="submit" value="register" />
</form>

In my forms.py I have

class RegistrationForm(forms.Form):
    username = forms.CharField(label=u'Username', max_length=30)
    first_name = forms.CharField(label=u'First Name', max_length=30)
    last_name = forms.CharField(label=u'Last Name', max_length=30)
    email = forms.EmailField(label=u'Email')
    password1 = forms.CharField(
                                label=u'Password',
                                widget=forms.PasswordInput()
                                )
    password2 = forms.CharField(
                                label=u'Password (Again)',
                                widget=forms.PasswordInput()
                                )

The problem is that every field is showing in a single row. how can I have different rows for all fields?

like image 663
Dimitris Avatar asked Dec 11 '12 18:12

Dimitris


1 Answers

{{form.as_table}} returns only <tr>...</tr> You would have to explicitly put the <table></table> wrapper around

You can read the documentation here

like image 70
karthikr Avatar answered Nov 03 '22 07:11

karthikr