Skip to content
Snippets Groups Projects
storage.py 361 B
Newer Older
  • Learn to ignore specific revisions
  • import unicodedata
    
    from django.core.files.storage import FileSystemStorage
    
    
    class ASCIIFileSystemStorage(FileSystemStorage):
        """
        Convert unicode characters in name to ASCII characters.
        """
    
    Eliot Berriot's avatar
    Eliot Berriot committed
    
    
        def get_valid_name(self, name):
    
    Eliot Berriot's avatar
    Eliot Berriot committed
            name = unicodedata.normalize("NFKD", name).encode("ascii", "ignore")
    
            return super().get_valid_name(name)