Python Forum
trying to display custom error message on form
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to display custom error message on form
#1
Hi,

I am trying to display a custom error message when the user enters a wrong password in a login form on my django app.
Currently, when the user enters a wrong password, it displays an error message saying "Invalid login". Also, not sure why it has a bullet point in front of it as well.

This is code in my login.html:

{% extends 'base.html' %}

{% block content %}

<form method="post">
	{% csrf_token %}

	{% for field in login_form %}
		<p>
			{{field.label_tag}}
			{{field}}

			{% if field.help_text %}
				{field.help_text}}
			{% endif %}
		</p>
	{% endfor %}

	{% for field in login_form %}
		{% for error in field.errors %}
			<p>{{error}}</p>
		{% endfor %}
	{% endfor %}

	{% if login_form.non_field_errors %}
		<p>{{login_form.non_field_errors}}</p>
	{% endif %}

	<button type="submit">login</button>	
</form>

{% endblock content %}
Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error Message Pip webdesign909 6 3,306 Feb-12-2018, 11:53 PM
Last Post: snippsat
  Display google recpatcha at the end of the form django-allauth app prithvi 2 4,144 Aug-08-2017, 09:19 PM
Last Post: prithvi
  Django allauth saving custom user profile fields with signup form prithvi 1 10,517 Aug-08-2017, 03:51 PM
Last Post: prithvi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020