1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

[1.10.x] Fixed #26900 -- Fixed crash accessing deferred FileFields.

Backport of 7c33aa8a87 from master
This commit is contained in:
Tim Graham
2016-07-15 15:54:11 -04:00
parent 6646a396cc
commit a03ac61332
3 changed files with 19 additions and 3 deletions

View File

@@ -188,6 +188,13 @@ class ImageFieldTests(ImageFieldTestMixin, TestCase):
loaded_p = pickle.loads(dump)
self.assertEqual(p.mugshot, loaded_p.mugshot)
def test_defer(self):
self.PersonModel.objects.create(name='Joe', mugshot=self.file1)
with self.assertNumQueries(1):
qs = list(self.PersonModel.objects.defer('mugshot'))
with self.assertNumQueries(0):
self.assertEqual(qs[0].name, 'Joe')
@skipIf(Image is None, "Pillow is required to test ImageField")
class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):