Ticket #7667: save_file.diff

File save_file.diff, 1.1 KB (added by oggy, 16 years ago)
  • django/db/models/fields/__init__.py

     
    832832    def save_file(self, new_data, new_object, original_object, change, rel, save=True):
    833833        upload_field_name = self.get_manipulator_field_names('')[0]
    834834        if new_data.get(upload_field_name, False):
    835             func = getattr(new_object, 'save_%s_file' % self.name)
    836835            if rel:
    837836                file = new_data[upload_field_name][0]
    838837            else:
    839838                file = new_data[upload_field_name]
    840839
     840            if not file:
     841                return
     842
    841843            # Backwards-compatible support for files-as-dictionaries.
    842844            # We don't need to raise a warning because Model._save_FIELD_file will
    843845            # do so for us.
     
    846848            except AttributeError:
    847849                file_name = file['filename']
    848850
     851            func = getattr(new_object, 'save_%s_file' % self.name)
    849852            func(file_name, file, save)
    850853
    851854    def get_directory_name(self):
Back to Top