1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #6302. FileField no longer requires a value if one already exists. Thanks Brian Rosner and Øyvind Saltvik.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7021 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2008-01-17 18:03:21 +00:00
parent 93c8e94bd6
commit fd20365b27
5 changed files with 128 additions and 10 deletions

View File

@@ -749,32 +749,59 @@ Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('', '')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('', 'files/test1.pdf')
'files/test1.pdf'
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None, '')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None, 'files/test2.pdf')
'files/test2.pdf'
>>> f.clean({})
Traceback (most recent call last):
...
ValidationError: [u'No file was submitted.']
>>> f.clean({}, '')
Traceback (most recent call last):
...
ValidationError: [u'No file was submitted.']
>>> f.clean({}, 'files/test3.pdf')
'files/test3.pdf'
>>> f.clean('some content that is not a file')
Traceback (most recent call last):
...
ValidationError: [u'No file was submitted. Check the encoding type on the form.']
>>> f.clean({'filename': 'name', 'content':None})
>>> f.clean({'filename': 'name', 'content': None})
Traceback (most recent call last):
...
ValidationError: [u'The submitted file is empty.']
>>> f.clean({'filename': 'name', 'content':''})
>>> f.clean({'filename': 'name', 'content': ''})
Traceback (most recent call last):
...
ValidationError: [u'The submitted file is empty.']
>>> type(f.clean({'filename': 'name', 'content':'Some File Content'}))
>>> type(f.clean({'filename': 'name', 'content': 'Some File Content'}))
<class 'django.newforms.fields.UploadedFile'>
>>> type(f.clean({'filename': 'name', 'content': 'Some File Content'}, 'files/test4.pdf'))
<class 'django.newforms.fields.UploadedFile'>
# URLField ##################################################################