files_25.py 339 B

1234567
  1. def pre_save(self, model_instance, add):
  2. "Returns field's value just before saving."
  3. file = super(FileField, self).pre_save(model_instance, add)
  4. if file and not file._committed:
  5. # Commit the file to storage prior to saving the model
  6. file.save(file.name, file, save=False)
  7. return file