I'm currently using:
- Python 3.3
- Django 1.6.5
- django-imagekit 3.2.1
- django-guardian (I don't think it's related, I can confirm the row-level permissions are correct on the Profile model)
I can't seem to change the profile image through a ModelForm. The ModelForm seems to update all the other fields attached to the model when submitted through an UpdateView (goes to success_url). I've tried using a plain ImageField and using a form-ProcessedImageField and that didn't work either. Strangely enough, I can in fact "delete" the image using the UpdateView (meaning the reference to the image is removed, it remains on the disk). Also, I can freely change the image in the Admin pages and it correctly generates the thumbnail too.
Not sure what else to try or what's going on here. Help would be greatly appreciated.
Model:
class Profile(models.Model):
...
avatar = ProcessedImageField(
upload_to=get_upload_filepath,
processors=[ResizeToFill(500, 500)],
format='JPEG',
blank=True,
default='img/200x200.gif'
)
avatar_thumbnail = ImageSpecField(
source='avatar',
processors=[ResizeToFill(200,200)],
format='JPEG',
options = {
'quality': 100
}
)
... some more fields
Helper function:
def get_upload_filepath(instance, filename):
return '/'.join(['img', instance.user.username, 'avatar.jpg'])
ModelForm:
class ProfileForm(ModelForm):
... overridden widgets on some fields
class Meta:
model = Profile
fields = ('first_name', 'last_name', 'birth_date', 'phone_number', 'avatar')
Edit:
form.cleaned_data['avatar'] is None
self.request.FILES is MultiValueDict: {}