Fixed #13328 -- Added a __getstate__/__setstate__ pair to fields so that callable default values aren't pickled. Thanks to bkonkle for the report, and Vitaly Babiy for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12977 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-04-15 12:41:08 +00:00
parent d9aaad4e36
commit 2faa3acb4b
6 changed files with 49 additions and 6 deletions

View file

@ -1,8 +1,9 @@
import pickle
import datetime
from django.test import TestCase
from models import Group, Event
from models import Group, Event, Happening
class PickleabilityTestCase(TestCase):
@ -12,3 +13,15 @@ class PickleabilityTestCase(TestCase):
def test_related_field(self):
g = Group.objects.create(name="Ponies Who Own Maybachs")
self.assert_pickles(Event.objects.filter(group=g.id))
def test_datetime_callable_default_all(self):
self.assert_pickles(Happening.objects.all())
def test_datetime_callable_default_filter(self):
self.assert_pickles(Happening.objects.filter(when=datetime.datetime.now()))
def test_lambda_as_default(self):
self.assert_pickles(Happening.objects.filter(name="test"))
def test_callable_as_default(self):
self.assert_pickles(Happening.objects.filter(number=1))