form = EmailForm()
return render_to_response('books/send_mail.html', {'email_form': form})
When i am using form.as_table in my template, all the fields are getting rendered in the same line : (Email: Subject: Message: )
.
How can i render these form fields in seperate lines using as_table. I dont want to use as_p or as_ul, because they do not have proper alignment.
The is_valid() method is used to perform validation for each field of the form, it is defined in Django Form class. It returns True if data is valid and place all data into a cleaned_data attribute.
{{ form.as_p }} – Render Django Forms as paragraph. {{ form.as_ul }} – Render Django Forms as list.
Django provides a Form class which is used to create HTML forms. It describes a form and how it works and appears. It is similar to the ModelForm class that creates a form by using the Model, but it does not require the Model.
cleaned_data returns a dictionary of validated form input fields and their values, where string primary keys are returned as objects. form. data returns a dictionary of un-validated form input fields and their values in string format (i.e. not objects).
Did you wrap your form in table tags?
You can also use form.as_table to output table rows (you'll need to provide your own tags)
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