1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #28555 -- Made CharField convert whitespace-only values to the empty_value when strip is enabled.

This commit is contained in:
Josh Schneier
2017-09-05 12:41:38 -04:00
committed by Tim Graham
parent 79ae5811c7
commit 48c394a6fc
2 changed files with 27 additions and 3 deletions

View File

@@ -221,11 +221,12 @@ class CharField(Field):
def to_python(self, value):
"""Return a string."""
if value not in self.empty_values:
value = str(value)
if self.strip:
value = value.strip()
if value in self.empty_values:
return self.empty_value
value = str(value)
if self.strip:
value = value.strip()
return value
def widget_attrs(self, widget):