Skip to content

Instantly share code, notes, and snippets.

@piotrkilczuk
Created September 13, 2011 09:11
Show Gist options
  • Save piotrkilczuk/1213462 to your computer and use it in GitHub Desktop.
Save piotrkilczuk/1213462 to your computer and use it in GitHub Desktop.
Store Django filenames as ASCII - ASCIIFileSystemStorage
from django.core.files.storage import FileSystemStorage
import unidecode
class ASCIIFileSystemStorage(FileSystemStorage):
"""
Convert unicode characters in name to ASCII characters.
"""
def get_valid_name(self, name):
name = unidecode.unidecode(name)
return super(ASCIIFileSystemStorage, self).get_valid_name(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment