上一页 1 2 3 4 5 6 ··· 20 下一页
摘要: F查询 使用 F() 避免竞争条件 F() 可以通过以下方式提供性能优势: 让数据库,而不是 Python 来完成工作, 避免了 竞争条件 减少某些操作所需的查询次数 如果两个 Python 线程执行修改一个字段的值的代码,一个线程可以在另一个线程从数据库中获取一个字段的值后,检索、递增并保存它。第 阅读全文
posted @ 2023-01-10 11:14 zong涵 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 在Django中使用内连接(子查询) Subquery() 模型类可能如下所示: class Category(models.Model): name = models.CharField(max_length=100) class Hero(models.Model): # ... name = 阅读全文
posted @ 2023-01-10 10:49 zong涵 阅读(485) 评论(0) 推荐(0) 编辑
摘要: django在视图中获取Template 现在对Template进行深入了解 在试图中使用模板(了解) 视图代码: from django.http import HttpResponse import datetime def current_datetime(request): now = da 阅读全文
posted @ 2023-01-09 17:17 zong涵 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Python imaplib下载邮件附件 代码如下: # 登陆邮箱并读取原始邮件 import imaplib import email from django.core.files import File import io def get_mail(username, passsword): # 阅读全文
posted @ 2022-12-30 15:00 zong涵 阅读(424) 评论(0) 推荐(0) 编辑
摘要: django聚合查询与分组查询 例题 聚合、分组查询 # 所有书的平均价格 avg_query = Book.objects.all().aggregate(Avg("price")) print(avg_query) # {'price__avg': Decimal('93.68888888888 阅读全文
posted @ 2022-11-23 22:04 zong涵 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Simple JWT 安装 pip install djangorestframework_simplejwt settings.py REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.a 阅读全文
posted @ 2022-11-22 22:05 zong涵 阅读(870) 评论(2) 推荐(1) 编辑
摘要: drf结合rest-pandas实现下载excel文件 下载rest-pandas pip install rest-pandas 使用方法 在views.py文件中 from rest_pandas.views import PandasViewBase from rest_pandas.rend 阅读全文
posted @ 2022-11-17 17:35 zong涵 阅读(328) 评论(0) 推荐(0) 编辑
摘要: Django出现RuntimeError: populate( ) isn't reentrant问题 问题描述 这个错误信息是一个笼统的错误信息,这里django把他真正的错误信息隐藏了。因此如果想得到真正的报错信息需要改源码,位置就在下方报错信息的"/Users/zonghan/PycharmP 阅读全文
posted @ 2022-11-10 11:56 zong涵 阅读(910) 评论(2) 推荐(1) 编辑
摘要: python PDF转图片 准备工作 下载模块pdf2image pip install pdf2image 下载依赖(不下载会报错) Mac brew install poppler 代码实现 from pdf2image import convert_from_path, convert_fro 阅读全文
posted @ 2022-11-08 13:38 zong涵 阅读(79) 评论(0) 推荐(0) 编辑
摘要: django FileResponse下载文件 代码如下: from django.http import FileResponse def get(self, request, *args, **kwargs): file_path = /Users/zonghan/Desktop/1.txt r 阅读全文
posted @ 2022-11-01 16:56 zong涵 阅读(548) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 20 下一页