Displaying forms
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 |
---|---|---|
|
<p><label for="id_name"> Name:</label> <input class="textinput textInput form-control" id="id_name" maxlength="100" name="name" type="text" /></p> <p><label for="id_age">Age:</label> <input class="numberinput form-control" id="id_age" name="age" type="number" /></p> | |
|
<li><label for="id_name">Name:</label> <input class="textinput textInput form-control" id="id_name" maxlength="100" name="name" type="text" /></li> <li><label for="id_age">Age:<... |