摘要: orm 创建时,如果是对象则用字段=对象,否则实用字段_id= id, student=student, student_id=student_id, 如果用student=student_id则报错must be a "Student" instance. 阅读全文
posted @ 2022-11-29 10:39 robertzhou 阅读(16) 评论(0) 推荐(0) 编辑
摘要: ![](https://img2022.cnblogs.com/blog/1534663/202209/1534663-20220902160250285-1976179402.jpg) ![](https://img2022.cnblogs.com/blog/1534663/202209/1534663-20220902160252983-1010776101.jpg) 阅读全文
posted @ 2022-09-02 16:03 robertzhou 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 出现原因 当您使用SessionAuthentication 时,您正在使用 Django 的身份验证,这通常需要检查 CSRF。Django REST Framework 强制执行此操作,仅适用于SessionAuthentication,因此您必须在X-CSRFToken标头中传递 CSRF 令 阅读全文
posted @ 2022-04-14 17:55 robertzhou 阅读(615) 评论(0) 推荐(0) 编辑
摘要: import os os.environ['DJANGO_SETTINGS_MODULE'] = 'taidii.settings' 阅读全文
posted @ 2022-01-07 15:54 robertzhou 阅读(44) 评论(0) 推荐(0) 编辑
摘要: import zipfile import StringIO import requests # 通过url获取zip文件 r = requests.get(url, stream=True) z = zipfile.ZipFile(StringIO.StringIO(r.content)) # 解 阅读全文
posted @ 2022-01-04 10:30 robertzhou 阅读(179) 评论(0) 推荐(0) 编辑
摘要: python2 1. 安装 PyMuPDF==1.16.6 2. import fitz def _pdf_to_image(self, pdf_path, file_data, image_dir): # 打开pdf with open(pdf_path, 'w') as f: f.write(f 阅读全文
posted @ 2022-01-04 10:19 robertzhou 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 首先确认自己git拉取代码的方式 git remote -v (以https方式连接远程仓库) origin https://github.com/(fetch) origin https://github.com/(push) 设置代理 http git config --global http. 阅读全文
posted @ 2021-05-24 09:47 robertzhou 阅读(1064) 评论(0) 推荐(1) 编辑
摘要: MongoDB副本集设置 安装 brew tap mongodb/brew brew install mongodb-community@4.4 启动 brew services start mongodb-community@4.4 关闭 brew services stop mongodb-co 阅读全文
posted @ 2021-03-30 17:21 robertzhou 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 深拷贝,浅拷贝 深拷贝,即将被复制对象完全再复制一遍作为独立的新个体单独存在。所以改变原有被复制对象不会对已经复制出来的新对象产生影响。 浅拷贝,并不会产生一个独立的对象单独存在,他只是将原有的数据块打上一个新标签,所以当其中一个标签被改变的时候,数据块就会发生变化,另一个标签也会随之改变。这就和我 阅读全文
posted @ 2020-12-11 16:19 robertzhou 阅读(97) 评论(0) 推荐(0) 编辑
摘要: django 路由 1.SimpleRouter from rest_framework.routers import SimpleRouter router = SimpleRouter() router.register(r'users', UserViewSet) register有两个强制参 阅读全文
posted @ 2020-12-11 15:09 robertzhou 阅读(872) 评论(0) 推荐(0) 编辑