diff options
| author | Tim Graham <timograham@gmail.com> | 2017-05-11 21:04:52 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-05-11 21:05:05 -0400 |
| commit | 74b0837bef6270a78f55878c488561f81a6339f7 (patch) | |
| tree | c6952387eab3c754dab91ab5b2e5149724f70934 /tests/model_fields | |
| parent | 643413f654d52ca4d7bf6d9402ff9ca24d2ea635 (diff) | |
[1.11.x] Fixed #28188 -- Fixed crash when pickling model fields.
Regression in d2a26c1a90e837777dabdf3d67ceec4d2a70fb86.
Thanks Adam Alton for the report and test, and Adam Johnson for
suggesting the fix.
Backport of a9874d48b1b9d91988b9f299726ec4f559fb2f75 from master
Diffstat (limited to 'tests/model_fields')
| -rw-r--r-- | tests/model_fields/tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py index a9c9794a3c..00f8338128 100644 --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -1,3 +1,5 @@ +import pickle + from django import forms from django.db import models from django.test import SimpleTestCase, TestCase @@ -76,6 +78,13 @@ class BasicFieldTests(TestCase): self.assertIsNotNone(f1) self.assertNotIn(f2, (None, 1, '')) + def test_field_instance_is_picklable(self): + """Field instances can be pickled.""" + field = models.Field(max_length=100, default='a string') + # Must be picklable with this cached property populated (#28188). + field._get_default + pickle.dumps(field) + class ChoicesTests(SimpleTestCase): |
