django
冷殇~
我很懒, 我又很勤快. 看对什么.
展开
-
django事务导致的死锁
这几个试着执行下就好了SHOW FULL PROCESSLIST;SELECT * FROM information_schema.INNODB_TRXwhere trx_mysql_thread_id in ();kill 111;原创 2022-02-07 08:48:12 · 1129 阅读 · 1 评论 -
djanog根据字段商(除数)
from django.db.models import F,ExpressionWrapper, DecimalField res = OrderDetails.objects.annotate( real_price=ExpressionWrapper(F('real_amount') / F("count"), output_field=DecimalField()) ).values('real_price')原创 2021-10-25 09:21:38 · 86 阅读 · 0 评论 -
djanog导出csv文件
def xlsx_response(x_io): res = HttpResponse() res["Content-Type"] = "text/csv" res["Content-Disposition"] = 'filename="aa.xlsx"' res.write(x_io.getvalue()) return resif query_params.get('export'): values_list_order = q.原创 2021-08-24 13:10:45 · 105 阅读 · 0 评论 -
django 文件上传下载
class FileStoreView(APIView): @staticmethod def read_file(url, chunk_size=512): with open(url, "rb") as f: while True: c = f.read(chunk_size) if c: yield c el.原创 2021-08-24 13:01:30 · 119 阅读 · 0 评论