摘要: 在视图类中可通过self.request来获取request对象,是因为源码中的dispatch将其封装到类中 def dispatch(self, request, *args, **kwargs): """ `.dispatch()` is pretty much the same as Dja 阅读全文
posted @ 2022-05-07 17:06 JiaMii 阅读(133) 评论(0) 推荐(0)
摘要: 在写一个判断是否为函数的逻辑传参时,发现 类名.方法名的指向为function地址 而通过self.方法名指向为bound method地址 以后注意判断是否为函数时记得用类名.方法名指向才能判断成功 阅读全文
posted @ 2022-04-05 03:06 JiaMii 阅读(16) 评论(0) 推荐(0)
摘要: 1.一定要在app内templatetags包中的py文件 2.使用时要引入django.template中的Library from django.template import Library register = Library() 阅读全文
posted @ 2022-02-26 22:04 JiaMii 阅读(27) 评论(0) 推荐(0)
摘要: 卸载旧版本安装新版本mysql时,出现了以下错误 TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see document 阅读全文
posted @ 2021-11-23 15:31 JiaMii 阅读(412) 评论(0) 推荐(0)
摘要: import threadingclass Singleton: instance = None lock = threading.RLock() def __init__(self):pass def __new__(cls, *args, **kwargs): if cls.instance: 阅读全文
posted @ 2021-01-11 02:42 JiaMii 阅读(64) 评论(0) 推荐(0)
摘要: 1.通过函数 from multiprocessing import Process def func(a,b,c): print(a,b,c) if __name__ == '__main__': #windows系统要加这句话,而linux不需要。原因是linux基于linux-fork,会把父 阅读全文
posted @ 2021-01-09 01:39 JiaMii 阅读(106) 评论(0) 推荐(0)
摘要: #server端import socket from multiprocessing import Process def talk(conn): while True: msg = conn.recv(1024).decode('utf-8') ret = msg.upper().encode(' 阅读全文
posted @ 2021-01-06 17:10 JiaMii 阅读(233) 评论(0) 推荐(0)