Skip to content

Instantly share code, notes, and snippets.

@neuman
Created March 5, 2015 21:52
Show Gist options
  • Save neuman/dccc268fd7d92bafde04 to your computer and use it in GitHub Desktop.
Save neuman/dccc268fd7d92bafde04 to your computer and use it in GitHub Desktop.
def get_file_path(instance, filename):
blocks = filename.split('.')
ext = blocks[-1]
filename = "%s.%s" % (uuid.uuid4(), ext)
instance.title = blocks[0]
return os.path.join('uploads/', filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment