【发布时间】:2020-12-28 14:56:22
【问题描述】:
我想在我的 excel_file 字段中保存一个文件,但我有这个错误:
'utf-8' 编解码器无法解码位置 15 中的字节 0x9d:无效起始字节
class Product(models.Model):
excel_file = models.FileField(upload_to='upload', blank=True)
def save(self, *args, **kwargs):
try :
myFile = open('excel_file.xlsx', 'r')
name = "new_test.xlsx"
self.excel_file.save(name, File(myFile))
super().save(*args, **kwargs)
except Exception as e:
print(e)
【问题讨论】:
标签: python django django-models