title: How to override save method of model to change filefield name?
body: <p>I have a ModelForm in my django app which allows a user to upload a file and store it to aws storage s3. What I wish to do is rename the file from its original name to the name of the field <code>timestamp</code>. What I have tried so far is overriding the save method of the model. Here is my code:</p>
  
  <p>models.py </p>
  
  <pre><code> from converter.storage_backends import CsvStorage
   from django.db import models
   from django.utils import timezone
   import time
  
  
  
   class CSVUpload(models.Model):
     csv_file = models.FileField(storage=CsvStorage())
     timestamp = models.CharField(max_length=1000, default= time.time())
  
     def __str__(self):
        return self.csv_file
  
  
     def save(self, *args, **kwargs):
      self.csv_file.name = self.timestamp + ".csv"
      super(CSVUpload, self).save(*args, **kwargs)
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>  from django import forms
    from .models import CSVUpload
    import time
  
    class CsvForm(forms.ModelForm):
  
    csv_file = forms.FileField(widget=forms.FileInput(
        attrs= {
          'class': 'form-group',
        }
     ))
  
    timestamp = forms.CharField(initial = time.time())
  
    class Meta:
      model = CSVUpload
      fields = ('csv_file', 'timestamp',)
  
    def save(self):
      csvfile = super(CsvForm, self).save()
      return csvfile
  </code></pre>
  
  <p>my view:</p>
  
  <pre><code> def uploadcsv(request):
     if request.method == 'POST':
        form = CsvForm(request.POST, request.FILES)
        if form.is_valid():
          return redirect(about)
     else:
      form = CsvForm()
      return render(request, 'myapp/uploadcsv.html',{'form': form})
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>storage_backends.py</p>
  
  <pre><code>  from storages.backends.s3boto3 import S3Boto3Storage 
    from django.conf import settings
  
    class CsvStorage(S3Boto3Storage):
       location = settings.AWS_CSV_LOCATION    
       file_overwrite = False
  </code></pre>
  
  <p>Despite that, when I upload the file it doesnt arrive on the bucket. I am not sure what is wrong but I suspect it lies on the save method. Could someone help me understand how to resolve this? I appreciate any help</p>