Wednesday, June 8, 2016

Re: Non Ascii character in upload file crash in python 3

After obj.save().

File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py" in save_base    736.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py" in _save_table    798.                       for f in non_pks]    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/base.py" in <listcomp>    798.                       for f in non_pks]    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/fields/files.py" in pre_save    311.             file.save(file.name, file, save=False)    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/db/models/fields/files.py" in save    93.             self.name = self.storage.save(name, content, max_length=self.field.max_length)    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py" in save    53.             name = self.get_available_name(name, max_length=max_length)    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py" in get_available_name    89.         while self.exists(name) or (max_length and len(name) > max_length):    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/site-packages/django/core/files/storage.py" in exists    294.         return os.path.exists(self.path(name))    File "/home/fondomutual/entornos/fomeucr/lib/python3.4/genericpath.py" in exists    19.         os.stat(path)    Exception Type: UnicodeEncodeError at /vistapublica/perfil/editar  Exception Value: 'ascii' codec can't encode character '\xd1' in position 74: ordinal not in range(128)  Request information:  GET: No GET data


2016-06-08 2:06 GMT-06:00 Stephen J. Butler <stephen.butler@gmail.com>:
Whats the stack trace?

On Wed, Jun 8, 2016 at 3:01 AM, Luis Zárate <luisza14@gmail.com> wrote:
$ python manage.py shell

>>> import sys
>>> sys.getfilesystemencoding()
'utf-8'



2016-06-08 1:57 GMT-06:00 Stephen J. Butler <stephen.butler@gmail.com>:
Have you tried this?


You probably have a system setup where ASCII is the filesystem encoding. It tells you a way to fix that on Linux/Unix.

On Wed, Jun 8, 2016 at 2:44 AM, Luis Zárate <luisza14@gmail.com> wrote:
Hi, 

I am having this issue in server production, I developed with python 3 and with others fields work great but when file is involved I don't know how to intermediate and remove non ascii characters.
Part of my stack trace is:
Internal Server Error: /vistapublica/perfil/editar    UnicodeEncodeError at /vistapublica/perfil/editar  'ascii' codec can't encode character '\xd1' in position 74: ordinal not in range(128)

FILES: foto = <ExcelInMemoryUploadedFile: ELI. ACUÑA 24 04 15.jpg (image/jpeg)>
So, how can I fix this issue?.



--
"La utopía sirve para caminar" Fernando Birri


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyPwsBhF_YSp-Htg_P24x9R2L0nzGgb9bOxsLBRmOr%2BP6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD4ANxUNNePQXj16Z_dOAgpueSobT%2BP0SJSN09J%2B8B3D7qUGrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyO_utrotMx%2B6mHs3r3ttA09Vinkd4o0yi1168gTxYHGMw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD4ANxU_5J7q5TSdzivvCEuMsmR_YJz%3Dk6nDUm5qpQ%3DRnEJWvQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyOf-D5p44VmQTR%2BeejtORuVPbotG%2BRkDavm0zDMWGmmeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment