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?
{{form.as_table}}
returns only <tr>...</tr>
You would have to explicitly put the <table></table>
wrapper around
You can read the documentation here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With