Created
September 13, 2011 09:11
-
-
Save piotrkilczuk/1213462 to your computer and use it in GitHub Desktop.
Store Django filenames as ASCII - ASCIIFileSystemStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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