我正在测试一些选项。我已经使用django-storages和S3上传了一个文件,并且工作正常。但是,当我尝试使用下面的代码读取文件时,出现以下错误:'FieldFile'对象没有属性'startswith'为什么?甚至default_storage.exists(self.filepath)也给出相同的错误。 csv_file = default_storage.open(self.filepath, 'r') new_object = CSVImport(csvfile=csv_file.read(), model=Contact, modelspy=".", mappings="1=first_name,2=mobile,3=email,4=last_name,5=43,6=16") new_object.run()
2 回答

慕村225694
TA贡献1880条经验 获得超4个赞
您正在将FieldFile
对象传递给,default_storage.open()
但是它希望文件名是字符串。为它提供用于保存文件的名称,而不是FieldFile
对象。
添加回答
举报
0/150
提交
取消