class ThumbnailImageField(models.ImageField):
def save_form_data(self, instance, data):
if data and isinstance(data, UploadedFile):
image = Image.open(data)
image.thumbnail((100, 120), Image.ANTIALIAS)
new_image = StringIO()
image.save(new_image, 'JPEG', quality=90)
data = SimpleUploadedFile(data.name, new_image.getvalue(), data.content_type)
super(ThumbnailImageField, self).save('filename.jpg', data)
TypeError at /users/ro/
'module' object is not callable
Request Method: POST
Request URL: http://127.0.0.1:8000/users/ro/
Exception Type: TypeError
Exception Value:
'module' object is not callable
Exception Location: /home/r/project/django/mysites/notary/apps/registration/fields.py in save_form_data, line 16
Python Executable: /usr/bin/python
Python Version: 2.5.2
PS
Если пишу new_image = StringIO # Это в строке 16 то получаю ошибку
AttributeError at /users/ro/
'module' object has no attribute 'write'
Request Method: POST
Request URL: http://127.0.0.1:8000/users/ro/
Exception Type: AttributeError
Exception Value:
'module' object has no attribute 'write'
Exception Location: /usr/lib/python2.5/site-packages/PIL/ImageFile.py in _save, line 479
Python Executable: /usr/bin/python
Python Version: 2.5.2