i want to render errors in each field
and remove the all from errors
{% csrf_token %}
{% if form.errors %}
<p><strong>{{form.errors}}</strong></p>
{% endif %}
<label>{{form.username.label}}</label>
{% render_field form.username class ='form-control border' %}
<br>
<label>{{form.password.label}}</label>
{% render_field form.password class ='form-control border' %}
<br>
<input type="submit" value="Login">
<p>don't have an account <a href="">Register</a> </p>
</form>
CodePudding user response:
you can loop for each field in your form and put an if statement to check if there is an errors in your form or you can do it manually for each field
{% if form.username.errors %}
{{form.username.errors}}
{#to do error handling #}
{% endif %}
CodePudding user response:
I'm presuming you want to enter errors for each field , if so you can check this out in the docs https://docs.djangoproject.com/en/4.1/topics/forms/#looping-over-the-form-s-fields