2018-03-25 15:40:37 +02:00
|
|
|
import unicodedata
|
|
|
|
|
|
|
|
|
|
from django.core.files.storage import FileSystemStorage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ASCIIFileSystemStorage(FileSystemStorage):
|
|
|
|
|
"""
|
|
|
|
|
Convert unicode characters in name to ASCII characters.
|
|
|
|
|
"""
|
2018-06-09 15:36:16 +02:00
|
|
|
|
2018-03-25 15:40:37 +02:00
|
|
|
def get_valid_name(self, name):
|
2018-06-09 15:36:16 +02:00
|
|
|
name = unicodedata.normalize("NFKD", name).encode("ascii", "ignore")
|
2018-03-25 15:40:37 +02:00
|
|
|
return super().get_valid_name(name)
|