skip to Main Content

My error messages are getting displayed on the top of the page, but also the messages are getting duplicated, meaning they are getting displayed next to the individual fields as well

 <div class="w3-half w3-center w3-border w3-round w3-border-black" style="width: 40%;">
    <div class="w3-card-4 w3-border w3-border-black w3-pale-blue" >
        <h4> Registration Form</h4>
    </div>
    
    <form method="post" action="">
  
        {% if form.errors %}
        <!-- {% for field, errors in form.errors.items %} -->
        <ul class="messages w3-red">
            {% for error in errors %}
            <li> {{ error }} </li>
            {% endfor %}
        </ul>
        <!-- {% endfor %} -->
        {% endif %}
        
        {% csrf_token %}
        {{form.as_p}}

    <input type="submit" class="w3-button w3-black w3-round  w3-hover-red" value="Register" style="margin-left: 25px;">
    </form>
    <p> Already signed up? Please <a href="{% url 'user_login' %}" > Login </a> </p>
       
</div>

Error Message

2

Answers


  1. Chosen as BEST ANSWER
    .errorlist {
      display: none;
    }
    

    Addind the above CSS suppressed the error functionality offered by UserCreationForm. This solved the duplication problem for me


  2. check your back-end validation. issue not in front-end

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search