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:
committed by
Tim Graham
parent
79ae5811c7
commit
48c394a6fc
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user