Problems to display the Form in the Template using CreateView

What happens is that I am using CreateView and I find it curious that the code works when I put {{form}}, it displays all the fields and saves in the database (everything works very well) but when I break down the values ​​one by one for example: {{form.plates}}, {{form.type}}, it does not send anything to the database and it stays on the same page. Why is that? I just need it broken down

clientes-add.html

<form enctype="multipart/form-data" method="post">
        {% csrf_token %}
         <div class="row mb-3">
             <div class="col-md-3">
                <div class="mb-3">
                     <label>Customer type</label>
                <br>
                 <div class="form-check form-check-inline">
                      {{ form.tipo }}
                   </div>

                 </div>
              </div>
            </div>
           <div class="row mb-3 only-corp hide-item">
                <div class="col-md-12">
                    <div class="mb-3">
                          <label>Corporation name</label>
                              {{ form.corporacion }}
                     </div>
                 </div>
            </div>
<button class="btn btn-primary mb-3" type="submit" value="Post">Save</button>
</form>



You also need to render {{form.fieldname.errors}} for each {{form.fieldname}}. The error will be telling you why the form is not valid, but you cannot see them!

You can test it if there is extra html you want to generate only if there are errors.

{% if form.fieldname.errors %} <br> {{form.fieldname.errors }} {% endif %}

Don't forget {{form.non_field_errors }}

Back to Top