diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-01-28 15:35:46 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-01-28 15:35:46 +0000 |
| commit | 00292ad02ebf9ff1cb09d586c2452b3a716fd601 (patch) | |
| tree | 2ffd3546659f49b2eed2626ab5cfdf508ba69fbf /django/db/models/fields | |
| parent | 398eca3fb2ac84304b179fabd2f0960228c59b09 (diff) | |
gis: Merged revisions 6990-7043 via svnmerge from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7044 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/fields')
| -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 e72f5015b7..383000d0aa 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -801,13 +801,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) |
