11 2022 档案
摘要:django聚合查询与分组查询 例题 聚合、分组查询 # 所有书的平均价格 avg_query = Book.objects.all().aggregate(Avg("price")) print(avg_query) # {'price__avg': Decimal('93.68888888888
阅读全文
摘要:Simple JWT 安装 pip install djangorestframework_simplejwt settings.py REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.a
阅读全文
摘要:drf结合rest-pandas实现下载excel文件 下载rest-pandas pip install rest-pandas 使用方法 在views.py文件中 from rest_pandas.views import PandasViewBase from rest_pandas.rend
阅读全文
摘要:Django出现RuntimeError: populate( ) isn't reentrant问题 问题描述 这个错误信息是一个笼统的错误信息,这里django把他真正的错误信息隐藏了。因此如果想得到真正的报错信息需要改源码,位置就在下方报错信息的"/Users/zonghan/PycharmP
阅读全文
摘要:python PDF转图片 准备工作 下载模块pdf2image pip install pdf2image 下载依赖(不下载会报错) Mac brew install poppler 代码实现 from pdf2image import convert_from_path, convert_fro
阅读全文
摘要:django FileResponse下载文件 代码如下: from django.http import FileResponse def get(self, request, *args, **kwargs): file_path = /Users/zonghan/Desktop/1.txt r
阅读全文