Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

777
Vistas
Is there a way to show login error in Django?

I have a custom login page for my web. Upon keying the right account details, I can log in to my web. But if I key in wrong account details, it just refreshes the pages with the username and password 's textbox empty. Is there some way to show something like 'Username or Password is wrong' as a error or message?

Within the login.html I have the following

{% if messages %}
{%for message in messages%}
<div class ="alert alert-success" role="alert">
{{message}}
</div>
{%endfor%}
{%endif%}

{% for field in form %}        
{% if field.errors %}        
{% for error in field.errors %}
<div class="alert alert-danger" role="alert">
 <div class="d-flex flex-row">
  <div class="align-middle pr-2">
   <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
                                                class="bi bi-x-circle-fill" viewBox="0 0 16 16">
                                                <path
                                                    d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
    </svg>
   </div>
  <div class="align-middle"><b>{{field.label}}</b> - {{error}}</div>
 </div>
</div>
{% endfor %}
{% endif %}
{% endfor %}

The following does not seem to do anything if the username or password is incorrect.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

try to add this in your template

{% if form.errors %}
    <p>username or password is wrong</p>
{% endif %}
over 4 years ago · Santiago Trujillo Denunciar

0

In any web application, we need to display notification messages to the end user after processing a form or some other types of his requests. To make this messaging system simple, Django provided full support to cookie and session based messaging for both anonymous and authenticated users.

This messages framework is capable of storing messages in one request and retrieving those messages in the subsequent request. Every message has a tag based on its priority(info,warning and error).

For more information click here.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda