title: How can I pre-process a file's contents being saved into a FileField in Django?
body: <p>There's a <code>.csv</code> being saved into a <code>FileField</code> in Django 2.2.</p>
  <p>Before it gets saved, I want to delete some rows in it.</p>
  <p>This is what I have so far:</p>
  <pre class="lang-py prettyprint-override"><code># A Custom File Field that will modify the file contents before saving it
  class CustomFileField(models.FileField):
      # The method that gets called before the save happens
      def pre_save(self, model_instance, add):
          file_field = super().pre_save(model_instance, add)
          file_field = self.update_file_contents(file_field)
          return file_field
  
      def update_file_contents(self, file_field):
          # NEED TO SOMEHOW UPDATE THE CONTENTS OF
          # THE file_field HERE BEFORE RETURNING IT
          return file_field
  
  # The model that uses this Custom File Field
  class MyModel(models.Model):
      my_csv_file = CustomFileField(upload_to='results/%Y/%m/%d/')
  </code></pre>
  <p>I'm not quite sure what my <code>update_file_contents</code> method needs to do to update the contents of the file. Has the file been saved to the filesystem by the time my method is called? Or is it still in memory?</p>
  <p>Or should I forget making a custom <code>FileField</code>, and simply override my <code>MyModel</code>'s <code>save</code> method, so that after the file is saved to the filesystem, I open it again, and modify it like I would any file?</p>