diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index 08ac441..380f892 100644
a
|
b
|
class FieldFile(File):
|
129 | 129 | if file is not None: |
130 | 130 | file.close() |
131 | 131 | |
132 | | def __getstate__(self): |
133 | | # FieldFile needs access to its associated model field and an instance |
134 | | # it's attached to in order to work properly, but the only necessary |
135 | | # data to be pickled is the file's name itself. Everything else will |
136 | | # be restored later, by FileDescriptor below. |
137 | | return {'name': self.name, 'closed': False, '_committed': True, '_file': None} |
138 | | |
139 | 132 | |
140 | 133 | class FileDescriptor(object): |
141 | 134 | """ |
diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py
index 90b7a65..c07199c 100644
a
|
b
|
class ImageFieldTests(ImageFieldTestMixin, TestCase):
|
164 | 164 | |
165 | 165 | def test_pickle(self): |
166 | 166 | """ |
167 | | Tests that ImageField can be pickled, unpickled, and that the |
168 | | image of the unpickled version is the same as the original. |
| 167 | Tests that ImageField and ImageFieldFile can be pickled, unpickled, |
| 168 | and that the image of the unpickled version is the same as the original. |
169 | 169 | """ |
170 | 170 | import pickle |
171 | 171 | |
| 172 | # Pickle the person (ImageField) |
172 | 173 | p = Person(name="Joe") |
173 | 174 | p.mugshot.save("mug", self.file1) |
174 | 175 | dump = pickle.dumps(p) |
… |
… |
class ImageFieldTests(ImageFieldTestMixin, TestCase):
|
179 | 180 | loaded_p = pickle.loads(dump) |
180 | 181 | self.assertEqual(p.mugshot, loaded_p.mugshot) |
181 | 182 | |
| 183 | # Pickle the mugshot (ImageFieldFile) |
| 184 | dump = pickle.dumps(p.mugshot) |
| 185 | loaded_mugshot = pickle.loads(dump) |
| 186 | self.assertEqual(p.mugshot.url, loaded_mugshot.url) |
| 187 | |
182 | 188 | |
183 | 189 | @skipIf(Image is None, "Pillow/PIL is required to test ImageField") |
184 | 190 | class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase): |