1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #10149. FileFields in a form now validate max_length. Based on a patch by Massimo Scamarcia.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10227 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2009-03-30 22:52:16 +00:00
parent 6ce25d3be9
commit fea6c73538
5 changed files with 28 additions and 2 deletions

View File

@@ -845,6 +845,21 @@ ValidationError: [u'The submitted file is empty.']
>>> type(f.clean(SimpleUploadedFile('name', 'Some File Content'), 'files/test4.pdf'))
<class 'django.core.files.uploadedfile.SimpleUploadedFile'>
>>> f = FileField(max_length = 5)
>>> f.clean(SimpleUploadedFile('test_maxlength.txt', 'hello world'))
Traceback (most recent call last):
...
ValidationError: [u'Ensure this filename has at most 5 characters (it has 18).']
>>> f.clean('', 'files/test1.pdf')
'files/test1.pdf'
>>> f.clean(None, 'files/test2.pdf')
'files/test2.pdf'
>>> type(f.clean(SimpleUploadedFile('name', 'Some File Content')))
<class 'django.core.files.uploadedfile.SimpleUploadedFile'>
# URLField ##################################################################
>>> f = URLField()