I recently created a django app that allows you to create projects, raise funding via social networks etc.
Because this is mainly based in Sweden we have to allow users to make use of NON-ASCII characters such as å ä ö and many other.
Easy way to get around this is to install UNIDECODE which handles all of this for you.
Each section/file you are going to make use of this remember to import unidecode
# Import of transliteration module
from unidecode import unidecode
To install
pip install Unidecode
Then clean your picture in your forms.py
def clean_picture(self):
data = self.cleaned_data['picture']
# For correct uploading non-ASCII image_filenames, we use transliteration module: unidecode()
# can be downloaded here: < git clone http://code.zemanta.com/tsolc/git/unidecode >
# Don't forget to import it: from unidecode import unidecode
trans_name = unidecode(data.name)
data.name = trans_name
return data
And in your views.p that handles the actual saving
if form.is_valid():
# For correct uploading non-ASCII image_filenames, we use transliteration module: unidecode()
# can be downloaded here: < git clone http://code.zemanta.com/tsolc/git/unidecode >
# Don't forget to import it: from unidecode import unidecode
cleaned_form = form.cleaned_data
trans_name = unidecode(cleaned_form['profile_picture'].name)
cleaned_form['profile_picture'].name = trans_name


It‘s quite in here! Why not leave a response?