mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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:
@@ -1,8 +1,20 @@
|
||||
import datetime
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
class Numbers(object):
|
||||
|
||||
@classmethod
|
||||
def get_number(self):
|
||||
return 2
|
||||
|
||||
class Group(models.Model):
|
||||
name = models.CharField(_('name'), max_length=100)
|
||||
|
||||
class Event(models.Model):
|
||||
group = models.ForeignKey(Group)
|
||||
|
||||
class Happening(models.Model):
|
||||
when = models.DateTimeField(blank=True, default=datetime.datetime.now)
|
||||
name = models.CharField(blank=True, max_length=100, default=lambda:"test")
|
||||
number = models.IntegerField(blank=True, default=Numbers.get_number)
|
||||
|
||||
Reference in New Issue
Block a user