Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

780
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda