diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-07-12 20:43:28 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-07-12 20:43:28 +0000 |
| commit | 5f73e2c4fa5f40f528d4d1d6999697e7f3f5248f (patch) | |
| tree | 545032dcd79d68793594ae7633912c2647e8a72c | |
| parent | c121ff4046263b37862f9aed5a6d7463794abb81 (diff) | |
Fixed #7667: fixied FileField.save_file for inline related objects. This is really just papering over a bigger problem that should get fixed either by newforms-admin or the file-storage refactoring, but this fix makes the admin work until either of those things happen. Thanks, oggy.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/models/fields/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 28111d86e1..545df612e4 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -835,12 +835,14 @@ class FileField(Field): def save_file(self, new_data, new_object, original_object, change, rel, save=True): upload_field_name = self.get_manipulator_field_names('')[0] if new_data.get(upload_field_name, False): - func = getattr(new_object, 'save_%s_file' % self.name) if rel: file = new_data[upload_field_name][0] else: file = new_data[upload_field_name] + if not file: + return + # Backwards-compatible support for files-as-dictionaries. # We don't need to raise a warning because Model._save_FIELD_file will # do so for us. @@ -849,6 +851,7 @@ class FileField(Field): except AttributeError: file_name = file['filename'] + func = getattr(new_object, 'save_%s_file' % self.name) func(file_name, file, save) def get_directory_name(self): |
