mirror of https://github.com/django/django.git
Fixed #5641 -- Handle lazy translations correctly when used as default arguments. Thanks, permon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6453 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4d8561a8a8
commit
185848a526
|
@ -238,7 +238,7 @@ class Field(object):
|
|||
if self.default is not NOT_PROVIDED:
|
||||
if callable(self.default):
|
||||
return self.default()
|
||||
return self.default
|
||||
return force_unicode(self.default, strings_only=True)
|
||||
if not self.empty_strings_allowed or (self.null and settings.DATABASE_ENGINE != 'oracle'):
|
||||
return None
|
||||
return ""
|
||||
|
|
|
@ -152,7 +152,7 @@ TypeError: 'foo' is an invalid keyword argument for this function
|
|||
>>> a6 = Article(pub_date=datetime(2005, 7, 31))
|
||||
>>> a6.save()
|
||||
>>> a6.headline
|
||||
'Default headline'
|
||||
u'Default headline'
|
||||
|
||||
# For DateTimeFields, Django saves as much precision (in seconds) as you
|
||||
# give it.
|
||||
|
|
|
@ -42,7 +42,7 @@ __test__ = {'API_TESTS':"""
|
|||
|
||||
# Access database columns via Python attributes.
|
||||
>>> a.headline
|
||||
'Default headline'
|
||||
u'Default headline'
|
||||
|
||||
# make sure the two dates are sufficiently close
|
||||
>>> d = now - a.pub_date
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
class TestModel(models.Model):
|
||||
text = models.CharField(max_length=10, default=_('Anything'))
|
||||
|
||||
__test__ = {'API_TESTS': '''
|
||||
>>> tm = TestModel()
|
||||
>>> tm.save()
|
||||
'''
|
||||
}
|
||||
|
Loading…
Reference in New Issue