mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #12734. Deferred fields will now be properly converted to python when accessed. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12579 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
21
tests/modeltests/field_subclassing/tests.py
Normal file
21
tests/modeltests/field_subclassing/tests.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from models import DataModel
|
||||
|
||||
|
||||
class CustomField(TestCase):
|
||||
def test_defer(self):
|
||||
d = DataModel.objects.create(data=[1, 2, 3])
|
||||
|
||||
self.assertTrue(isinstance(d.data, list))
|
||||
|
||||
d = DataModel.objects.get(pk=d.pk)
|
||||
self.assertTrue(isinstance(d.data, list))
|
||||
self.assertEqual(d.data, [1, 2, 3])
|
||||
|
||||
d = DataModel.objects.defer("data").get(pk=d.pk)
|
||||
d.save()
|
||||
|
||||
d = DataModel.objects.get(pk=d.pk)
|
||||
self.assertTrue(isinstance(d.data, list))
|
||||
self.assertEqual(d.data, [1, 2, 3])
|
||||
Reference in New Issue
Block a user