上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 49 下一页
摘要: content_disposition = response对象.headers.get("content-disposition") 阅读全文
posted @ 2023-06-20 09:59 tslam 阅读(421) 评论(0) 推荐(0)
摘要: 如下 在项目中全局搜索FileResponse可找见 class ExportPlugin(BaseAdminPlugin): export_mimes = {'xlsx': 'application/vnd.ms-excel', 'xls': 'application/vnd.ms-excel', 阅读全文
posted @ 2023-06-20 09:57 tslam 阅读(48) 评论(0) 推荐(0)
摘要: 1 先从内存中查找 2 再从内置模块中查找 3 再从python解释器系统中key为path的环境变量中从上往下查找, 找到一个就结束. 都没找到则报错. py文件命名注意: 不要与 内置模块名冲突. 阅读全文
posted @ 2023-06-14 20:53 tslam 阅读(29) 评论(0) 推荐(0)
摘要: views.py 重写 list方法 阅读全文
posted @ 2023-06-13 19:46 tslam 阅读(16) 评论(0) 推荐(0)
摘要: 鼠标点击ValidationError(), 再点击PyCharm右侧对应两个按钮, 找见源码 如下 结论: 你可以直接传dict 或 list内容 阅读全文
posted @ 2023-06-13 16:59 tslam 阅读(38) 评论(0) 推荐(0)
摘要: 分析: 我们返回给前端的是Response对象, 要给Response加减内容,首先得找见它. 所以步骤是 1.1 找见Response 1.2 给Response添加/减少/改变东西, 返回新的Response 1.1 返回Response 位置 -> 五个视图扩展类里 from rest_fra 阅读全文
posted @ 2023-06-13 15:54 tslam 阅读(58) 评论(0) 推荐(0)
摘要: 有对应的excel协议, 具体: 前端掉 excel协议+文件地址即可,你只需要把 文件地址 返回即可. 背景: http协议: http"//www.baidu.com https协议 ftp协议 所以,对应的有 Excel协议 阅读全文
posted @ 2023-06-12 09:27 tslam 阅读(124) 评论(0) 推荐(0)
摘要: put 请求,报错如题 其中的url url(r'books/', views.BookView.as_view()),path('books/<int:pk>', views.BookView2.as_view())原因:第一条url后没加$, put请求被第一条url匹配到, 第一个url是ge 阅读全文
posted @ 2023-06-04 12:12 tslam 阅读(36) 评论(0) 推荐(0)
摘要: 是Django模型字段定义中一个参数,用于指定模型字段的默认值. 详细解释: 在创建新的模型实例时,若没有为phone字段提供具体的值,那么该字段将被默认设置为空字符串. 例: my_object = MyModel.objects.create(name='John'), 中没有为phone字段提 阅读全文
posted @ 2023-06-01 11:01 tslam 阅读(307) 评论(0) 推荐(0)
摘要: 1 背景: 模型表中字段为: phone = models.CharField(default='', max_length=64, verbose_name=u'电话', blank=True) 2 分析: 在保存模型实例时, ‘phone’被设置为空值. 但是该字段在数据库中被设置为(NOT N 阅读全文
posted @ 2023-06-01 11:00 tslam 阅读(572) 评论(0) 推荐(0)
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 49 下一页