1、课程回顾
1、大纲
2、wsgi:他就是socket服务端
3、 硬盘不值钱,不使用FK
单表查询快,数据量大,不会使用FK,允许出现数据冗余
FK 用户量少,节省硬盘
4、序列化操作 new:构造方法
类的实例化
1. ListSerializer对象
2. return 当前类的对象
5、列表生成式
6、反射找到中间件
根据字符串,反射找到模块对应的类
restframe源码
7、反射demo
crsf.py
class CORS(object): def process_request(self): print('666')
run.py
path = "auth.crsf.CORS" import importlib module_path,class_name = path.rsplit('.',maxsplit=1) print(module_path) # auth.crsf print(class_name) # CORS # 根据字符串的形式导入模块 m = importlib.import_module(module_path) # # auth.crsf cls = getattr(m,class_name) obj = cls() # 实例化 obj.process_request()