django 2.2.21 文件路径

问题描述

因为 django 做了这个安全问题

https://www.djangoproject.com/weblog/2021/may/04/security-releases/

我无法打开测试数据文件: 我正在使用

import os
from django.core.files import File
file = File(os.path.join(os.path.dirname(__file__),"data","tests","test_pdf.pdf"))

然后

Model.objects.create(name="test". file=file)

出现错误:

 django.core.exceptions.SuspiciousFileOperation: File name 'apps/app/data/tests/test_pdf.pdf' includes path elements

有什么解决办法吗?或者加载 pdf 的正确方法是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)