一)Django WEB框架
2)
request.path和
request.get_full_path() 是请求的路径 3)render:页面渲染 4)redirect:页面跳转
3)模板语法:
1模板的组成:HTML + 逻辑控制语法 2,逻辑控制代码的组成: 变量(使用大括号来引用变量): 语法格式: {{var_name}}
./manage.py shell 进入django 环境 from django.template import Context, Template >>> t = Template("<h1>hello {{name}}</h1>") >>> c = Context({"name":"wangyue"}) >>> t.render(c) '<h1>hello wangyue</h1>'
4)模板语法{{}}
参考网址:https://code.ziqiangxuetang.com/django/django-template2.html
可以html文件中传递list,dict和类,字典的取值比如:{{current.name}}
传Animal类 class Animal(): def __init__(self,name,age): self.name = name self.age = age
def query(request): l = ["1","2"] #列表 d = {"name":"wang","age":25} #字典 animal = Animal("zhaozhen","35") # return render(request, "showtime.html",{"curren_time":d}) return render(request, "showtime.html",{"animal":animal}) # return render(request, "showtime.html",{"curren_time":l})