mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #24818 -- Prevented models.CharField from accepting a string as max_length
This commit is contained in:
parent
ae1efb853c
commit
d091b75eef
2 changed files with 18 additions and 6 deletions
|
@ -129,6 +129,22 @@ class CharFieldTests(IsolatedModelsTestCase):
|
|||
]
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
def test_str_max_length_value(self):
|
||||
class Model(models.Model):
|
||||
field = models.CharField(max_length='20')
|
||||
|
||||
field = Model._meta.get_field('field')
|
||||
errors = field.check()
|
||||
expected = [
|
||||
Error(
|
||||
"'max_length' must be a positive integer.",
|
||||
hint=None,
|
||||
obj=field,
|
||||
id='fields.E121',
|
||||
),
|
||||
]
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
def test_non_iterable_choices(self):
|
||||
class Model(models.Model):
|
||||
field = models.CharField(max_length=10, choices='bad')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue