Is this login fail? or?

when click login the page no blank to home page just stay in login page
the terminal show me "GET /login/?csrfmiddlewaretoken=LK82SQKdzu802NaUuXom8CWRn3S86WWK0XrzEqFCCrUmGGCe06MXoMgFtt0JLDRN&username=tim&password=tim123 HTTP/1.1" 200 3148 and the browser link this http://127.0.0.1:8000/login/?csrfmiddlewaretoken=MWNadf5CSlSmTnCFIlJ5aoJDKHL1ShJJ196HZP01ViEIxg4Zeu7Gqy3rQ7TCxYEM&username=tim&password=tim123

login.html

{% extends "main/base.html" %}

{% block title %}
  Login Here
{% endblock title %}

{% load crispy_forms_tags %}

{% block content %}
  <form class="from-group" method="get">
    {% csrf_token %}
    {{form | crispy}}
    <button type="submit" class="btn btn-success">Login</button>
    <p>Don't have an account? Create one <a href="/register">Here</a></p>
  </form>
{% endblock content %}

settings.py (i just skip to STARIC it so long

STATIC_URL = 'static/'

CRISPY_TEMPLATE_PACK = "bootstrap4" (add) 

LOGIN_REDIRECT_URL = "/" (add)

urls.py

from django.contrib import admin
from django.urls import path, include
from register import views as v

urlpatterns = [
    path('admin/', admin.site.urls),
    path('register/', v.register, name='register'),
    path('', include('main.urls')),
    path('', include('django.contrib.auth.urls')),
]

>Solution :

I think you got this message in terminal because of form method get. For login form, it must be POST not GET.

instead of this:

<form class="from-group" method="get">

Try this:

<form class="from-group" method="post">

Leave a Reply