摘要: CBV添加装饰器 创建一个装饰器用于判断用户是否登录 def login_auth(func): def inner(request, *args, **kwargs): if request.COOKIES.get('username'): return func(request, *args, 阅读全文
posted @ 2021-08-20 21:21 Gnomeshghy 阅读(40) 评论(0) 推荐(0)
摘要: 批量插入数据 第一种插入方式(插入多少条数据就要操作多少次数据库,效率低,不推荐使用) for i in range(10000): models.Book.objects.create(title='%s本书' % i) 第二种插入方式(循环大量的对象,通过bulk.create方法一次性插入数据 阅读全文
posted @ 2021-08-20 16:37 Gnomeshghy 阅读(107) 评论(0) 推荐(0)