diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-01-17 18:03:21 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-01-17 18:03:21 +0000 |
| commit | fd20365b277bf48dbdbd82afa1346eadb96d9574 (patch) | |
| tree | 1e02d91fca33fb2fd52ff26125fe788470da4e3a /django/newforms/forms.py | |
| parent | 93c8e94bd6b004ae7a97502e664e6a530958ed9a (diff) | |
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
Diffstat (limited to 'django/newforms/forms.py')
| -rw-r--r-- | django/newforms/forms.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 556c00a777..04bf62e445 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 TextInput, Textarea from util import flatatt, ErrorDict, ErrorList, ValidationError @@ -182,7 +182,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)() |
