From daa467d79ec7b40e376294eabc51222a67690181 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Thu, 17 Jan 2008 18:12:24 +0000 Subject: newforms-admin: Merged from trunk up to [7021]. git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7022 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'django/newforms/forms.py') diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 88d5f8b3df..9e1b576710 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -9,7 +9,7 @@ from django.utils.html import escape from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode from django.utils.safestring import mark_safe -from fields import Field +from fields import Field, FileField from widgets import Media, media_property, TextInput, Textarea from util import flatatt, ErrorDict, ErrorList, ValidationError @@ -205,7 +205,11 @@ class BaseForm(StrAndUnicode): # widgets split data over several HTML fields. value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) try: - value = field.clean(value) + if isinstance(field, FileField): + initial = self.initial.get(name, field.initial) + value = field.clean(value, initial) + else: + value = field.clean(value) self.cleaned_data[name] = value if hasattr(self, 'clean_%s' % name): value = getattr(self, 'clean_%s' % name)() -- cgit v1.3