标签:url input pass cti method tle lan alias ali
========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>
标签:url input pass cti method tle lan alias ali
原文地址:https://www.cnblogs.com/dongmengze/p/9674169.html