1

I've to put in the fields of the form individually because for me its a little easier to style, my issue is that I can't seem to get it to display the error messages on validation. The form validates correctly, it just doesnt show what errors I get when I do get an error, instead it just doesnt submit. How can I fix this?

Template:

    <form  action="#" method="post"> {%csrf_token%} {{form.management_form}}



    {%for f in form%} 
    {{ f.non_field_errors }}


    <div class="row">

   <div class="medium-3 columns ">
   <label> First Name
   {{ member_fname.errors }}
    {{f.member_fname}}
  </label>
    </div>

  <div class="medium-3 columns ">
    <label> Last Name
      {{ member_lname.errors }}

        {{f.member_lname}}
   </label>
  </div>

  <div class="medium-3 columns ">
   <label> Email
      {{ member_email.errors }}

      {{f.member_email}}
   </label>
 </div>

<div class="medium-3 columns ">
<label> Phone #
   {{ member_phone.errors }}

    {{f.member_phone}}
</label>
</div>

 </div>
 <hr/>
 {%endfor%}
 <div class="row">
  <div class="small-3 columns small-centered">
 <button type="submit" class="button medium radius"> submit</button>
 </div>
  </div>
 </div>
 </form>

1 Answer 1

2

Syntax for rendering validation errors:

{{ form.fieldname.errors }}

This will show validation errors in a list format and if you want to render them as text then use:

{{ form.fieldname.errors.as_text }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.