diff options
| author | Jannis Leidel <jannis@leidel.info> | 2012-03-03 19:02:49 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2012-03-03 19:02:49 +0000 |
| commit | c988397279147b9d38c5b3feed9647c586fa049a (patch) | |
| tree | a4aede19b7a5e69718ddbf7c92a12633abbfa255 /django | |
| parent | dc49e6143a1e3cfafa4b7b41e4ab3c86d3e68918 (diff) | |
Fixed #10498 -- Fixed using ugettext_lazy values when creating model instances. Thanks to Claude Paroz and Jonas Obrist.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17641 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index fc38224345..53b62df135 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -20,7 +20,7 @@ from django.db.models.options import Options from django.db.models import signals from django.db.models.loading import register_models, get_model from django.utils.translation import ugettext_lazy as _ -from django.utils.functional import curry +from django.utils.functional import curry, Promise from django.utils.encoding import smart_str, force_unicode from django.utils.text import get_text_list, capfirst @@ -297,10 +297,14 @@ class Model(object): # is *not* consumed. We rely on this, so don't change the order # without changing the logic. for val, field in izip(args, fields_iter): + if isinstance(val, Promise): + val = force_unicode(val) setattr(self, field.attname, val) else: # Slower, kwargs-ready version. for val, field in izip(args, fields_iter): + if isinstance(val, Promise): + val = force_unicode(val) setattr(self, field.attname, val) kwargs.pop(field.name, None) # Maintain compatibility with existing calls. @@ -354,6 +358,8 @@ class Model(object): # checked) by the RelatedObjectDescriptor. setattr(self, field.name, rel_obj) else: + if isinstance(val, Promise): + val = force_unicode(val) setattr(self, field.attname, val) if kwargs: |
