摘要:
1.在应用(如:app01)下创建文件夹templatetags 再创建一个py文件,编写自定义标签(如:mytag) 2.编写自定义标签 from django import template register = template.Library() @register.filter(name= 阅读全文
posted @ 2023-11-29 21:33
wellplayed
阅读(45)
评论(0)
推荐(0)
摘要:
1.Template和Context的导入 from django.template import Template, Context 2.生成静态页面 ——在后端调用模板语法生成HTML页面,并保存到指定路径 2.1 我们想生成一个前端页面,代码如下 后端视图层传入的对象: user_data = 阅读全文
posted @ 2023-11-29 20:50
wellplayed
阅读(168)
评论(0)
推荐(0)
摘要:
绑定给类的方法,类来调用,对象可以调用吗? # 首先创建一个类,和绑定给类的方法index class MyClass: @classmethod def index(cls): print("hello index") 实例化对象: obj = MyClass() 使用对象调用绑定给类的方法: o 阅读全文
posted @ 2023-11-29 17:23
wellplayed
阅读(35)
评论(0)
推荐(0)
摘要:
1.路由配置 path('index/', 视图类名.as_view()) # as_view是类的绑定方法 2.执行流程(分析) path('index/', index), >请求来了,路由匹配成功会执行 index(request,) path('index/', UserView.as_vi 阅读全文
posted @ 2023-11-29 15:20
wellplayed
阅读(26)
评论(0)
推荐(0)
摘要:
1.视图层返回JsonResponse return JsonResponse({'name':'kevin','age':19}) 2.触发 JsonResponse 的__init__方法 将{'name':'kevin','age':19}传给data 3.源码分析 def __init__( 阅读全文
posted @ 2023-11-29 15:09
wellplayed
阅读(59)
评论(0)
推荐(0)

浙公网安备 33010602011771号