今日概要:
1、name别名
2、模版的深度查询
3、模版语言之filter
4、自定义过滤器,filter和simpletag的区别
5、orm进阶
扫盲:url的组成
URL:协议+域名+端口+路径 eg:http://www.cnblogs.com/drango/articles/6811632.html?a=1
协议:http
域名:www.cnblogs.com
端口:80
路径:drango/articles/6811632.html
数据:a=1
URL配置中的正则表达式匹配的是一个url的路径部分
1、url之name别名
设置别名的用途:可以随意在urls.py里更改传入url,不会影响模版渲染
用法: {% url 'REG' %}
''' urlpatterns = [ url(r'^index',views.index,name='INDEX'), ] ################### def index(req): if req.method=='POST': username=req.POST.get('username') password=req.POST.get('password') if username=='alex' and password=='123': return HttpResponse("登陆成功") return render(req,'index.html') ##################### <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> {# <form action="/index/" method="post">#} <form action="{% url 'INDEX' %}" method="post"> 用户名:<input type="text" name="username"> 密码:<input type="password" name="password"> <input type="submit" value="submit"> </form> </body> </html> ####################### '''