码迷,mamicode.com
首页 > Web开发 > 详细

url别名

时间:2018-09-19 14:45:37      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:url   input   pass   cti   method   tle   lan   alias   ali   

  • url别名的使用  "{% url ‘login_alias‘ %}"

========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别名

标签:url   input   pass   cti   method   tle   lan   alias   ali   

原文地址:https://www.cnblogs.com/dongmengze/p/9674169.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!