diff --git a/django/forms/fields.py b/django/forms/fields.py
index 96ecabf..1fa8d57 100644
a
|
b
|
class ImageField(FileField):
|
577 | 577 | |
578 | 578 | # Since we're about to use the file again we have to reset the |
579 | 579 | # file object if possible. |
580 | | if hasattr(file, 'reset'): |
581 | | file.reset() |
| 580 | if hasattr(file, 'seek') and callable(file.seek): |
| 581 | file.seek(0) |
582 | 582 | |
583 | 583 | # verify() is the only method that can spot a corrupt PNG, |
584 | 584 | # but it must be called immediately after the constructor |
diff --git a/tests/modeltests/model_forms/tests.py b/tests/modeltests/model_forms/tests.py
index a2ad024..ff5048e 100644
a
|
b
|
class OldFormForXTests(TestCase):
|
1370 | 1370 | self.assertEqual(instance.image.name, 'foo/test4.png') |
1371 | 1371 | instance.delete() |
1372 | 1372 | |
| 1373 | # Test image field when cStringIO is not available |
| 1374 | from django.forms import fields |
| 1375 | from StringIO import StringIO |
| 1376 | old_StringIO = fields.StringIO |
| 1377 | fields.StringIO = StringIO |
| 1378 | try: |
| 1379 | f = ImageFileForm( |
| 1380 | data={'description': u'An image'}, |
| 1381 | files={'image': SimpleUploadedFile('test.png', image_data)}) |
| 1382 | self.assertEqual(f.is_valid(), True) |
| 1383 | finally: |
| 1384 | fields.StringIO = old_StringIO |
| 1385 | |
1373 | 1386 | def test_media_on_modelform(self): |
1374 | 1387 | # Similar to a regular Form class you can define custom media to be used on |
1375 | 1388 | # the ModelForm. |