Click here to Skip to main content
15,442,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a simple login form with username and password. My login is not redirecting to the LOGIN_REDIRECT_URL link which should redirect to the home page. I tried several credentials from the admin side(which I got from signing up)

Urls.py:
from django.contrib import admin
from django.urls import path
from jobs import views as jobs_views      #from the job application it is gonna import views
from users import views as users_views
from django.contrib.auth import views as auth_views
urlpatterns = [
path('login/', auth_views.LoginView.as_view(template_name = 'login.html'), name= 'login'),]


Login.html(Form):

<section class="site-section">
        <div class="container">
          <div class="row">
            {% csrf_token %}
            {{ form.non_field_errors }}
            <!-- DEBUG -->
                      {% for field in form %}
                          {% if field.errors %}{{ field.html_name }}: {{ field.errors }}{% endif %}
                      {% endfor %}
            
            <div class="col-lg-6">
              <h2 class="mb-4">Log In To JobBoard</h2>
              <form class="p-4 border rounded", submit= 'POST'>
  
                <div class="row form-group">
                  <div class="col-md-12 mb-3 mb-md-0">
                    <label class="text-black" for="fname">Username</label>
                    {{ form.username }}
                  </div>
                </div>
                <div class="row form-group mb-4">
                  <div class="col-md-12 mb-3 mb-md-0">
                    <label class="text-black" for="fname">Password</label>
                    {{ form.password }}
                  </div>
                </div>
  
                <div class="row form-group">
                  <div class="col-md-12">
                    <input type="submit" value="Log In" class="btn px-4 btn-primary text-white">
                  </div>
                </div>
  
              </form>
            </div>
          </div>
        </div>
      </section>


What I have tried:

I tried putting
{{ form.non_field_errors }}
            <!-- DEBUG -->
                      {% for field in form %}
                          {% if field.errors %}{{ field.html_name }}: {{ field.errors }}{% endif %}
                      {% endfor %}

to get errors and display so that I know but it is not working
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900