Answers for "django custom modelform html"

0

django custom modelform html

<!-- will render inputs wrapped in <li> tags-->
{{ form.as_ul }} 

<!-- will render inputs wrapped in <p> tags -->
{{ form.as_p }}

<!-- will render in <tr> tags (add your own table tags) -->
{{ form.as_table }}

<!-- add each input manually -->
{{ form.non_field_errors }}
<div class="fieldWrapper">
    {{ form.yourfield.errors }}
    <label for="{{ form.yourfield.id_for_label }}">yourfield:</label>
    {{ form.yourfield }}
</div>

<!-- loop through each input field -->
{% for field in form %}
    <div class="fieldWrapper">
        {{ field.errors }}
        {{ field.label_tag }} {{ field }}
        {% if field.help_text %}
        <p class="help">{{ field.help_text|safe }}</p>
        {% endif %}
    </div>
{% endfor %}
Posted by: Guest on September-15-2021

Browse Popular Code Answers by Language