summaryrefslogtreecommitdiff
path: root/django/forms/__init__.py
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2006-06-01 20:47:34 +0000
committerLuke Plant <L.Plant.98@cantab.net>2006-06-01 20:47:34 +0000
commitdbcd2fe985498889e1206f54c196f00879e79dae (patch)
tree60029eac8135a7113143d957cd791636128b591b /django/forms/__init__.py
parentfa9722489b792cf05e43e3a09309faaeb9109660 (diff)
Fixed #2045 - TypeError thrown if a form does not have the correct enctype for uploading
files. It throws a ValidationError now, as it should. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3048 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/__init__.py')
-rw-r--r--django/forms/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/forms/__init__.py b/django/forms/__init__.py
index 52092aff7b..b67e1d0f84 100644
--- a/django/forms/__init__.py
+++ b/django/forms/__init__.py
@@ -641,7 +641,11 @@ class FileUploadField(FormField):
self.validator_list = [self.isNonEmptyFile] + validator_list
def isNonEmptyFile(self, field_data, all_data):
- if not field_data['content']:
+ try:
+ content = field_data['content']
+ except TypeError:
+ raise validators.CriticalValidationError, gettext("No file was submitted. Check the encoding type on the form.")
+ if not content:
raise validators.CriticalValidationError, gettext("The submitted file is empty.")
def render(self, data):