开发者

Django: How to update Photo model that uses Imagekit without re-uploading photo on save()

开发者 https://www.devze.com 2023-02-05 11:41 出处:网络
I have a Photo model that I want to update.When I try to save I get errors from my s3 bucket as well as validation errors about certain fields cannot be null.I think I understand why it is doing this,

I have a Photo model that I want to update. When I try to save I get errors from my s3 bucket as well as validation errors about certain fields cannot be null. I think I understand why it is doing this, it assumes this is a totally new image upload, but all I want to do is edit th开发者_StackOverflowe title. How can I accomplish this? Any help would be greatly appreciated.


Your file storage shouldn't be called unless the file associated with your FileField has changed. In your case, I don't see a reason why s3 should ever even get hit by doing a simple photo.title = 'New title'; photo.save()

It could be lots of other issues, granted, I haven't tried Imagekit yet (very nice app!), but I'm guessing something, somewhere is inadvertently altering your ImageField file data. I suggest you write a simple test that edits an existing Photo model instance and debug the issue thoroughly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号