英文:
Django admin request got values for both 'fields' and 'body' error when trying to save entry with CloudinaryField attribute
问题
I am working on a Django project and suddenly I have found that when the user tries to save a new entry with an image there is an exception:
"request got values for both 'fields' and 'body', can only specify one."
I am using the Django Admin in conjunction with the Cloudinary library where I am using the CloudinaryField on the specific table.
In addition, I have a one-to-many relationship between MainEntity and Picture. The Picture model holds a CloudinaryField.
When I am trying to use traceback
to get a detailed error, I am getting another error related to the database:
"An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block."
The problem arises when I am calling the save method manually after the overridden that I have made in the Picture model:
def save(self, *args, **kwargs):
if not self.order:
self.order = self.mainEntity.number_of_pictures() + 1
try:
super(Picture, self).save(*args, **kwargs)
except BaseException:
traceback.print_exc()
What I have found is that the exception happens in request_encode_body
method that you can find in this URL.
Although, I cannot understand why this is happening and what causes this issue!
Thank you!
What I have tried in detail
I have tried to downgrade Cloudinary and Django dependencies to the versions that I was using from the beginning of the project.
Checked the Cloudinary credentials.
Found the documentation of the method that throws the exception and tried to investigate more.
英文:
I am working on a Django project and suddenly I have found that when user tries to save a new entry with an image there is an exception:
request got values for both 'fields' and 'body', can only specify one
I am using the Django Admin in conjunction with the Cloudinary library where I am using the CloudinaryField on the specific table.
In addition, I have one to many relationship between MainEntity and Picture. The Picture model holds a CloudinaryField.
When I am trying to use traceback
to get a detailed error I am getting another error related with database:
An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
The problem arises when I am calling the save method manually after the overridden that I have made in Picture model:
def save(self, *args, **kwargs):
if not self.order:
self.order = self.mainEntity.number_of_pictures() + 1
try:
super(Picture, self).save(*args, **kwargs)
except BaseException:
traceback.print_exc()
What I have found is that the exception happens in request_encode_body
method that you can find in this url.
Although, I cannot understand why this is happening and what causes this issue!
Thank you!
What I have tried in detail
I have tried to downgrade Cloudinary and Django dependencies to the versions that I was using from the beginning of the project.
Checked the Cloudinary credentials.
Found the documentation of the method that throws the exception and try to investigate more.
答案1
得分: 1
我曾经遇到和你一样的问题。我使用的是 Cloudinary 的 1.23.0 版本。在升级到 1.33.0(最新版本)之后,问题得到解决。尝试升级你的 Cloudinary 依赖。
英文:
I'had the exact same problem as you.
I was using the 1.23.0 version of Cloudinary.
After upgrading it to the 1.33.0 (last current version) it works again.
Try upgrading your Cloudinary dependency.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论