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 the title. How can I accomplish this? Any help would be greatly appreciated.
Asked
Active
Viewed 445 times
1

Mariusz Jamro
- 30,615
- 24
- 120
- 162

django-d
- 2,210
- 3
- 23
- 41
-
Please provide more information on where do you get those errors. Is it on django admin page? Is it in a form written by you? If it is your code you could paste some of it. Does it work in django shell? If you didn't try to change the title in django-shell, then try it. – Ski Jan 18 '11 at 13:03
1 Answers
2
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.

Filip Dupanović
- 32,650
- 13
- 84
- 114
-
Wow, that worked. I was doing the following, photo = Photo(id = formed.cleaned_data['img'].id, title = formed.cleaned_data[title]) I changed to photo = Photo.objects.get(id = form.cleaned_data['img'].id) ;photo.title = "Yeah it worked"; photo.save() and it worked. – django-d Jan 19 '11 at 04:03