lets start by create a form.

First, create a forms.py file inside the directory of your blog application and make it look like this:

forms.py

1
2
3
4
5
#forms.py
from django import forms
class login_Form(forms.Form):
    username = forms.CharField(max_length=25)
    password = forms.CharField(widget=forms.PasswordInput)

views.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#view.py
from .forms import *
def login(request):
    form = login_Form()
    # Handling forms
    if request.method == "POST":
        form = login_Form(request.POST)
        if form.is_valid():
            return HttpResponse('The form has been sent')
        else:
           form = login_Form()  
    return render(request, 'login.html', {'form':form})

urls.py

1
2
#url.py
path('login', login, name='form_login'),

login.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#login.html
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<form action="{% url 'form_login' %}" method="POST">
{% csrf_token %}
{{form}}
<input type="submit" name="submit" value="POST">
</form>
</body>
</html>

after submit the form we'll get this message

The form has been sent

English today is not an art to be mastered it's just a tool to use to get a result