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.
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.