【问题标题】:Input abc.png of type: <class 'django.core.files.uploadedfile.InMemoryUploadedFile'> is not supported不支持输入 abc.png 类型:<class \'django.core.files.uploadedfile.InMemoryUploadedFile\'>
【发布时间】: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()

【问题讨论】:

    标签: python django


    【解决方案1】:

    Ab_弗雷多,

    请问,你能给错误更多的上下文吗? 另外,image_file 的来源是什么?

    赛尔

    【讨论】:

      猜你喜欢
      • 2021-12-01
      • 2022-01-15
      • 2021-05-26
      • 2021-06-02
      • 2020-07-21
      • 2018-09-24
      • 2020-09-29
      • 2020-06-24
      • 2023-03-30
      相关资源
      最近更新 更多