Skip to content

Instantly share code, notes, and snippets.

@MattTheRed
Created June 4, 2013 13:48
Show Gist options
  • Select an option

  • Save MattTheRed/5706058 to your computer and use it in GitHub Desktop.

Select an option

Save MattTheRed/5706058 to your computer and use it in GitHub Desktop.
Class TehModel(models.Models):
file = models.FileField(upload_to=self.sort_files_by_extension, max_length=255)
def sort_files_by_extension(self, filename):
ext = os.path.splitext(filename)[1]
ext = ext.lower()
return "formats/%s" % ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment