summaryrefslogtreecommitdiff
path: root/django/db/models
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2008-01-17 18:12:24 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2008-01-17 18:12:24 +0000
commitdaa467d79ec7b40e376294eabc51222a67690181 (patch)
treea91a72f3c10e95bf5c59a2599c0d370ddc8c78dc /django/db/models
parentc080e441f347ad252be5e2d4dc56e9f43fce88cc (diff)
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
Diffstat (limited to 'django/db/models')
-rw-r--r--django/db/models/fields/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 0ea4eae6e7..a41217fef0 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -795,13 +795,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)