mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #33406 -- Avoided creation of MaxLengthValidator(None) when resolving Value.output_field for strings.
This brings the behaviour in line with Field subclasses which append to the validators within __init__(), like BinaryField, and prevents the creation of a validator which incorrectly throws a TypeError, if it were used.
This commit is contained in:
parent
b894199eb0
commit
0ed2919814
@ -1010,6 +1010,7 @@ class CharField(Field):
|
|||||||
def __init__(self, *args, db_collation=None, **kwargs):
|
def __init__(self, *args, db_collation=None, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.db_collation = db_collation
|
self.db_collation = db_collation
|
||||||
|
if self.max_length is not None:
|
||||||
self.validators.append(validators.MaxLengthValidator(self.max_length))
|
self.validators.append(validators.MaxLengthValidator(self.max_length))
|
||||||
|
|
||||||
def check(self, **kwargs):
|
def check(self, **kwargs):
|
||||||
|
@ -1859,6 +1859,7 @@ class ValueTests(TestCase):
|
|||||||
and this demonstrates that they don't throw an exception.
|
and this demonstrates that they don't throw an exception.
|
||||||
"""
|
"""
|
||||||
value_types = [
|
value_types = [
|
||||||
|
'str',
|
||||||
True,
|
True,
|
||||||
42,
|
42,
|
||||||
3.14,
|
3.14,
|
||||||
|
Loading…
Reference in New Issue
Block a user