summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRolo <rolo@wildfish.com>2015-06-04 11:24:53 +0100
committerTim Graham <timograham@gmail.com>2015-06-04 09:02:54 -0400
commit19e67c6cd13d6442abb2a6eba1b7fba80dcf5457 (patch)
tree13b4d9df48887ac90b09835d5b0f62c60efb3557 /django
parentdfdcb3ca226023c4166c69abccc7f627ea69aa80 (diff)
Fixed #24677 -- Made TextField.to_python() return a string.
This is consistent with CharField.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index e6fa29a565..3215927ea0 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -2141,12 +2141,15 @@ class TextField(Field):
def get_internal_type(self):
return "TextField"
- def get_prep_value(self, value):
- value = super(TextField, self).get_prep_value(value)
+ def to_python(self, value):
if isinstance(value, six.string_types) or value is None:
return value
return smart_text(value)
+ def get_prep_value(self, value):
+ value = super(TextField, self).get_prep_value(value)
+ return self.to_python(value)
+
def formfield(self, **kwargs):
# Passing max_length to forms.CharField means that the value's length
# will be validated twice. This is considered acceptable since we want