18.Form rendering options in edit.html page for django project



 
  • {{ form.as_table }} will render them as table cells wrapped in <tr> tags

<h1>add contact</h1>
<form action="{% url 'contacts-new' %}" method="post">
  {% csrf_token %}

  <ul>
  {{ form.as_table }}

  </ul>
<input id='save_contact' type="submit" value="save"/>

   
</form>
<a href="{% url 'contacts-list' %}">back to list</a>
 

Output
==========================================

add contact

back to list
=============================================


  • {{ form.as_p }} will render them wrapped in <p> tags
<h1>add contact</h1>
<form action="{% url 'contacts-new' %}" method="post">
  {% csrf_token %}

  <ul>
  {{ form.as_p }}

  </ul>
<input id='save_contact' type="submit" value="save"/>

   
</form>
<a href="{% url 'contacts-list' %}">back to list</a>
 
================================
Output

add contact




back to list

 =====================================

  • {{ form.as_ul }} will render them wrapped in <li> tags 

<h1>add contact</h1>
<form action="{% url 'contacts-new' %}" method="post">
  {% csrf_token %}

  <ul>
  {{ form.as_ul }}

  </ul>
<input id='save_contact' type="submit" value="save"/>

   
</form>
<a href="{% url 'contacts-list' %}">back to list</a>






Output

 =================

add contact

back to list
 ============================

No comments:

Post a Comment