I am new to Django and I am stuck with this issue. I am trying to create a login page where the user enters his/her username and password and Submit to go to the next page. For now just to test, I want to print a text saying " successfully logged in" when the user enters id and password in my login page itself.
This is my urls.py
from django.urls import path
from . import views
urlpatterns = [
path('login',views.log, name = 'login'),
]
This is my Views.py
from django.shortcuts import render
def log(request):
return render(request, 'login_page.html')
def verify_num(request):
username = request.GET['uname']
password = request.GET['pass']
grant = 'successfully logged in'
if username == 'harish' and password == 'harish':
return render(request, 'login_page.html',{'access':grant})
And this is my html page.
{% extends 'base.html' %}
{% block content %}
<h1 align = 'center'><b>LOGIN</b></h1>
<form action = '' align ='center'>
Enter Username: <input type = 'text' name = 'uname' text-align :'center'><br><br>
Enter Password: <input type = 'password' , name = 'pass' align = 'center'><br><br>
<input type= 'submit'><br>
<h3 >{{access}} </h3>
</form>
{% endblock %}
How do I call my funtion verify_num in views.py so that the text saying "Successfully logged in" prits