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/db | |
| 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/db')
| -rw-r--r-- | django/db/models/fields/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 139a096b68..f78c81ae39 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -797,13 +797,17 @@ class FileField(Field): return os.path.normpath(f) def save_form_data(self, instance, data): - if data: + from django.newforms.fields import UploadedFile + if data and isinstance(data, UploadedFile): getattr(instance, "save_%s_file" % self.name)(data.filename, data.content, save=False) def formfield(self, **kwargs): defaults = {'form_class': forms.FileField} # If a file has been provided previously, then the form doesn't require # that a new file is provided this time. + # The code to mark the form field as not required is used by + # form_for_instance, but can probably be removed once form_for_instance + # is gone. ModelForm uses a different method to check for an existing file. if 'initial' in kwargs: defaults['required'] = False defaults.update(kwargs) |
