url别名
Posted dongmengze
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了url别名相关的知识,希望对你有一定的参考价值。
- 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别名的主要内容,如果未能解决你的问题,请参考以下文章
SSM-MyBatis-05:Mybatis中别名,sql片段和模糊查询加getMapper
结合两个代码片段?将用户输入的 Youtube url 转换为嵌入 url,然后将 iframe src 替换为转换后的 url