mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #20594 -- Add validation to models.SlugField.
Thanks carbonXT for the report.
This commit is contained in:
parent
675558d00e
commit
dc9c359546
4 changed files with 9 additions and 6 deletions
|
@ -19,6 +19,7 @@ class ModelToValidate(models.Model):
|
|||
email = models.EmailField(blank=True)
|
||||
url = models.URLField(blank=True)
|
||||
f_with_custom_validator = models.IntegerField(blank=True, null=True, validators=[validate_answer_to_universe])
|
||||
slug = models.SlugField(blank=True)
|
||||
|
||||
def clean(self):
|
||||
super(ModelToValidate, self).clean()
|
||||
|
|
|
@ -53,7 +53,11 @@ class BaseModelValidationTests(ValidationTestCase):
|
|||
|
||||
def test_text_greater_that_charfields_max_length_raises_erros(self):
|
||||
mtv = ModelToValidate(number=10, name='Some Name'*100)
|
||||
self.assertFailsValidation(mtv.full_clean, ['name',])
|
||||
self.assertFailsValidation(mtv.full_clean, ['name'])
|
||||
|
||||
def test_malformed_slug_raises_error(self):
|
||||
mtv = ModelToValidate(number=10, name='Some Name', slug='##invalid##')
|
||||
self.assertFailsValidation(mtv.full_clean, ['slug'])
|
||||
|
||||
|
||||
class ArticleForm(forms.ModelForm):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue