Django forms also help you create an HTML representation of your form. They support three different representations: as_p (as paragraph tags), as_ul (as unordered list items), and as_table (as, unsurprisingly, a table).
The template code, generated HTML code, and browser rendering for each of these representations have been summarized in the following table:
Template |
Code |
Output in Browser |
{{ form.as_p }} |
<p><label for="id_name">Name:</label> <input type="text" name="name" maxlength="100" required id="id_name" /></p> <p><label for="id_age">Age:</label> <input type="number" name="age" required id="id_age" /></p> |
|
{{ form.as_ul }} |
<li><label for="id_name">Name... |