【发布时间】:2022-11-11 14:40:36
【问题描述】:
无法在 django 中保存图像两次
我试图通过一个模型中的表单保存图像并添加到另一个模型中。但是在 new_account.save() 我得到了上述错误。
image_file = request.FILES.get('profile_image')
...
...
instance.save()
new_account = Account.objects.get(id=classroom_profile.user.id)
new_account.profile_image.delete()
new_account.profile_image = image_file
new_account.save()
【问题讨论】: