========urls.py========
from django.conf.urls import include, url
from app01 import views
urlpatterns = [
    url(r‘^login/$‘, views.login, name=‘login_alias‘),
]
========views.py========
def login(request):
    if request.method == ‘POST‘:
        name = request.POST.get(‘username‘)
        pwd = request.POST.get(‘pwd‘)
        return HttpResponse(‘login success!‘)
    return render(request, ‘login.html‘)
========login.html========
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<form action="/login/" method="post">
    <input type="text" name="username">
    <input type="password" name="pwd">
    <input type="submit" value="submit">
</form>
</body>
</html>
========login.html========
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<form action="{% url ‘login_alias‘ %}" method="post">
    <input type="text" name="username">
    <input type="password" name="pwd">
    <input type="submit" value="submit">
</form>
</body>
</html>
原文:https://www.cnblogs.com/dongmengze/p/9674169.html