title: Django: presave signal to get file extension in Model
body: <p>In Django, for file field, its possible to use callable for example <code>user_directory_path</code> in the code below.</p>
  
  <pre><code>def user_directory_path(instance, filename):
      # file will be uploaded to MEDIA_ROOT/user_&lt;id&gt;/&lt;filename&gt;
      return 'user_{0}/{1}'.format(instance.user.id, filename)
  
  class MyModel(models.Model):
      upload = models.FileField(upload_to=user_directory_path)
  extension = models.CharField(max_length=100, null=False, blank=False, default=get_filename_ext)
  </code></pre>
  
  <p>However, for the extension field I want to use the <code>get_filename_ext</code> function so that extension of the file gets saved.</p>
  
  <pre><code>def get_filename_ext(filepath):
      base_name = os.path.basename(filepath)
      name, ext = os.path.splitext(base_name)
      return name, ext
  </code></pre>
  
  <p>Is there something similar in Django model? Or do I have to do this in Django view?</p>