Re: 'ascii' codec can't encode character

2022-04-29 Thread David Crandell
You'd actually want to handle UNICODE strings, not ASCII.

https://docs.djangoproject.com/en/4.0/ref/unicode/

On Thursday, April 28, 2022 at 7:02:49 PM UTC-5 Thiago Luiz Parolin wrote:

> Hi,
> i have a model with 2 charfields for givenname, surname:
>
>nome = models.CharField(
> max_length=150,
> verbose_name=_("Nome"),
> default=''
> )
> sobrenome = models.CharField(
> max_length=150,
> verbose_name=_("Sobrenome"),
> default=''
> )
>
> My modelForm does nothing, just defines a model at Meta with all fields.
> My CreateView is just defined with all default values, not overriding 
> anything.
> When submitting the form, the server returns 500 if 'nome' or 'sobrenome' 
> fields have accent letters like Á, é, í, ç. etc.
>
> The error:
> 'ascii' codec can't encode character '\xe9' in position 4: ordinal not in 
> range(128)
> with character depending on user input.
>
> I am using sqlite for db and the pragma encoding returns utf8.
>
> I don't know how to deal with it.
> Any help would be appreciated.
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bed1cb7c-6442-4ec7-b137-9c235e828d25n%40googlegroups.com.


Re: 'ascii' codec can't encode character

2022-04-29 Thread Antonis Christofides
Hi, could you post the full traceback? And if some part of this traceback refers 
to your code, it would be a good idea to also show us that part of your code.



On 29/04/2022 03.01, Thiago Luiz Parolin wrote:

Hi,
i have a model with 2 charfields for givenname, surname:

   nome = models.CharField(
        max_length=150,
        verbose_name=_("Nome"),
        default=''
    )
    sobrenome = models.CharField(
        max_length=150,
        verbose_name=_("Sobrenome"),
        default=''
    )

My modelForm does nothing, just defines a model at Meta with all fields.
My CreateView is just defined with all default values, not overriding anything.
When submitting the form, the server returns 500 if 'nome' or 'sobrenome' 
fields have accent letters like Á, é, í, ç. etc.


The error:
'ascii' codec can't encode character '\xe9' in position 4: ordinal not in 
range(128)

with character depending on user input.

I am using sqlite for db and the pragma encoding returns utf8.

I don't know how to deal with it.
Any help would be appreciated.

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANbmKyvUWshdM3ENz9LjbG66rLkt4vruM6cC9M-%3DKmL7rcCR%2Bg%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CANbmKyvUWshdM3ENz9LjbG66rLkt4vruM6cC9M-%3DKmL7rcCR%2Bg%40mail.gmail.com?utm_medium=email_source=footer>.


--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eafa7d28-9a14-7216-d5a9-46d230cc1530%40antonischristofides.com.


'ascii' codec can't encode character

2022-04-28 Thread Thiago Luiz Parolin
Hi,
i have a model with 2 charfields for givenname, surname:

   nome = models.CharField(
max_length=150,
verbose_name=_("Nome"),
default=''
)
sobrenome = models.CharField(
max_length=150,
verbose_name=_("Sobrenome"),
default=''
)

My modelForm does nothing, just defines a model at Meta with all fields.
My CreateView is just defined with all default values, not overriding
anything.
When submitting the form, the server returns 500 if 'nome' or 'sobrenome'
fields have accent letters like Á, é, í, ç. etc.

The error:
'ascii' codec can't encode character '\xe9' in position 4: ordinal not in
range(128)
with character depending on user input.

I am using sqlite for db and the pragma encoding returns utf8.

I don't know how to deal with it.
Any help would be appreciated.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANbmKyvUWshdM3ENz9LjbG66rLkt4vruM6cC9M-%3DKmL7rcCR%2Bg%40mail.gmail.com.


Re: Ayuda con el error: UnicodeEncodeError: 'ascii' codec can't encode character '\xf3' in position 7: ordinal not in range(128)

2019-05-07 Thread Phako Perez
Al parecer estás usando un carácter como ñ o ç, el cual es de los extendidos, 
supongo intentas settear el password o el nombre de usuario, intenta con puro 
carácter sin acentos o tilde ni ninguna otra forma rara.

Sent from my iPhone

> On May 7, 2019, at 16:21, noel moreira  wrote:
> 
> Hola amigos, me podrían ayudar aresolver este error:
> 
> UnicodeEncodeError: 'ascii' codec can't encode character '\xf3' in position 
> 7: ordinal not in range(128)}
> 
> Esto me paso cuando estaba creando el super usuario en django
> 
> -- 
> 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+unsubscr...@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/0e0d233e-b0d5-4253-aa21-343ef48518b8%40googlegroups.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+unsubscr...@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/E9963FCD-DB44-4454-9D89-FA8132EEDFA3%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Ayuda con el error: UnicodeEncodeError: 'ascii' codec can't encode character '\xf3' in position 7: ordinal not in range(128)

2019-05-07 Thread noel moreira
Hola amigos, me podrían ayudar aresolver este error:

UnicodeEncodeError: 'ascii' codec can't encode character '\xf3' in position 
7: ordinal not in range(128)}

Esto me paso cuando estaba creando el super usuario en django

-- 
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+unsubscr...@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/0e0d233e-b0d5-4253-aa21-343ef48518b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 'ascii' codec can't encode character u'\xe4' [solved]

2012-06-15 Thread kenneth gonsalves
On Thu, 2012-06-14 at 08:26 -0700, bruno desthuilliers wrote:
> > apache + wsgi 
> >
> 
> 
> Ok, so that's the same setup we use... Are you/they using the 
> WSGIDaemonProcess and WSGIProcessGroup directives ? (I bet they do if
> it's 
> shared hosting and they know what's good for them).

yes
>  But anyway: I did not 
> test the damn thing thoroughly but IIRC the problem appeared whether 
> running daemon or embedded mode - the django process env is stil
> inherited 
> from the Apache process. Using os.setenv in the .wsgi script is
> _supposed_ 
> to cure the problem but our experience (here again I did not have time
> to 
> really explore the problem :-/) is that it often doesn't work (can't
> even 
> tell if it ever worked at all), so we alway end up editing apache conf
> - 
> which _is_ a know working solution.

they give users a small snippet of httpd.conf which we can edit - I put
this line:

SetEnv Locale UTF8

and it is working. Thanks for the hints, I now remember that I had
solved this problem long ago, but it is so long since I have used
apache, that i had forgotten 
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread Xavier Ordoquy
Hi there,

I have faced this kind of error a couple of times when the local wasn't 
correctly set on the system.
Within the python interpreter it was  C (ie ascii) where it should have been 
UTF8.
Up to now, all have been resolved by correctly setting the locals system wide 
and within the web server (see apache setenv as mentioned in earlier post).

Regards,
Xavier Ordoquy,
Linovia.

Le 15 juin 2012 à 07:36, kenneth gonsalves a écrit :

> On Thu, 2012-06-14 at 23:46 +0200, Hendrik Speidel wrote:
>> as an alternative you can provide your own Storage implementation like
>> outlined here:
>> 
>> http://source.mihelac.org/2011/02/6/rename-uploaded-files-ascii-character-set-django/
>> 
>> 
> 
> I have told the client to use only ascii for the time being - but that
> is not a solution - for example assume that the same files are
> accessed/uploaded by other applications. 
> -- 
> regards
> Kenneth Gonsalves
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread kenneth gonsalves
On Thu, 2012-06-14 at 23:46 +0200, Hendrik Speidel wrote:
> as an alternative you can provide your own Storage implementation like
> outlined here:
> 
> http://source.mihelac.org/2011/02/6/rename-uploaded-files-ascii-character-set-django/
> 
> 

I have told the client to use only ascii for the time being - but that
is not a solution - for example assume that the same files are
accessed/uploaded by other applications. 
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread Hendrik Speidel
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/base.py"
> in save
>   464. self.save_base(using=using, force_insert=force_insert,
> force_update=force_update)
> File
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/base.py"
> in save_base
>   552. result = manager._insert([self], fields=fields,
> return_id=update_pk, using=using, raw=raw)
> File
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/manager.py"
> in _insert
>   203. return insert_query(self.model, objs, fields, **kwargs)
> File
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/query.py"
> 
> in insert_query
>   1576. return
> query.get_compiler(using=using).execute_sql(return_id)
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/sql/compiler.py"
> in execute_sql
>   909. for sql, params in self.as_sql():
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/sql/compiler.py"
> in as_sql
>   872. for obj in self.query.objs
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/fields/files.py"
> in pre_save
>   249. file.save(file.name <http://file.name>, file,
> save=False)
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/fields/files.py"
> in save
>   86. self.name <http://self.name> = self.storage.save(name,
> content)
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py"
> in save
>   44. name = self.get_available_name(name)
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py"
> in get_available_name
>   70. while self.exists(name):
> File
> 
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py"
> in exists
>   230. return os.path.exists(self.path(name))
> File "/usr/local/lib/python2.7/genericpath.py" in exists
>   18. os.stat(path)
> 
> Exception Type: UnicodeEncodeError at /admin/web/download/add/
> Exception Value: 'ascii' codec can't encode character u'\xe4' in
> position 71: ordinal not in range(128)
> 
> 
> -- 
> regards
> Kenneth Gonsalves
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/3B3Y--yCilsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread Paulo Almeida
insert_query 
>   1576. return 
> query.get_compiler(using=using).execute_sql(return_id) 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/sql/compiler.py"
>  
> in execute_sql 
>   909. for sql, params in self.as_sql(): 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/sql/compiler.py"
>  
> in as_sql 
>   872. for obj in self.query.objs 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/fields/files.py"
>  
> in pre_save 
>   249. file.save(file.name, file, save=False) 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/fields/files.py"
>  
> in save 
>   86. self.name = self.storage.save(name, content) 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py" 
> in save 
>   44. name = self.get_available_name(name) 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py" 
> in get_available_name 
>   70. while self.exists(name): 
> File 
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py" 
> in exists 
>   230. return os.path.exists(self.path(name)) 
> File "/usr/local/lib/python2.7/genericpath.py" in exists 
>   18. os.stat(path) 
>
> Exception Type: UnicodeEncodeError at /admin/web/download/add/ 
> Exception Value: 'ascii' codec can't encode character u'\xe4' in 
> position 71: ordinal not in range(128) 
>
>
> -- 
> regards 
> Kenneth Gonsalves 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/3B3Y--yCilsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread bruno desthuilliers


On Thursday, June 14, 2012 1:58:28 PM UTC+2, lawgon wrote:
>
> On Thu, 2012-06-14 at 04:19 -0700, bruno desthuilliers wrote: 
> > > I have an application which runs on a webfaction hosting. 
> > 
> > 
> > 
> > How is it deployed exactly ? 
>
> apache + wsgi 
>


Ok, so that's the same setup we use... Are you/they using the 
WSGIDaemonProcess and WSGIProcessGroup directives ? (I bet they do if it's 
shared hosting and they know what's good for them). But anyway: I did not 
test the damn thing thoroughly but IIRC the problem appeared whether 
running daemon or embedded mode - the django process env is stil inherited 
from the Apache process. Using os.setenv in the .wsgi script is _supposed_ 
to cure the problem but our experience (here again I did not have time to 
really explore the problem :-/) is that it often doesn't work (can't even 
tell if it ever worked at all), so we alway end up editing apache conf - 
which _is_ a know working solution.

Your best bet here is to first try the os.setenv trick, and if it doesn't 
solve the problem contact webfaction and see what you / they can do.

HTH (and please report the solution)

 

> > (sorry never used webfaction hosting for django - nor for anything 
> > else 
> > FWIW) 
>
> not my choice, client choice 
> >   
> > 
> > > I also have 
> > > the same app running on my devel machine. The code in the two 
> > machines 
> > > are pulled from the same repo. Django versions are identical. 
> > Python 
> > > versions are identical. I try to upload a file called Lisäinfo 
> > > kummeille.pdf in the dev machine. No problem. When I try the same 
> > file 
> > > in webfaction, I get the above error. I have checked and find I can 
> > use 
> > > python to open and save a file of the same name from the python 
> > prompt 
> > > in the webfaction shell. In templates, admin and and generated 
> > pdfs, 
> > > these non ascii characters are handled perfectly. Has anyone got 
> > any 
> > > clues about this? 
> > 
> > 
> > 
> > 
> > Each time I had this problem, it happened that the server process was 
> > using 
> > Apache's default locale, and that Apache default's locale was "C", not 
> > the 
> > utf8 locale configured for users. Not much of a problem for me since I 
> > have 
> > admin access but that may not be the case with webfaction :-/ 
>
> I think that should be it - my dev server runs nginx (and on my own 
> server I have root and anyway do not use apache. 
>
> -- 
> regards 
> Kenneth Gonsalves 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Plu2MEPmJ40J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread kenneth gonsalves
On Thu, 2012-06-14 at 04:19 -0700, bruno desthuilliers wrote:
> > I have an application which runs on a webfaction hosting.
> 
> 
> 
> How is it deployed exactly ? 

apache + wsgi 
> (sorry never used webfaction hosting for django - nor for anything
> else 
> FWIW)

not my choice, client choice
>  
> 
> > I also have 
> > the same app running on my devel machine. The code in the two
> machines 
> > are pulled from the same repo. Django versions are identical.
> Python 
> > versions are identical. I try to upload a file called Lisäinfo 
> > kummeille.pdf in the dev machine. No problem. When I try the same
> file 
> > in webfaction, I get the above error. I have checked and find I can
> use 
> > python to open and save a file of the same name from the python
> prompt 
> > in the webfaction shell. In templates, admin and and generated
> pdfs, 
> > these non ascii characters are handled perfectly. Has anyone got
> any 
> > clues about this?
> 
> 
> 
> 
> Each time I had this problem, it happened that the server process was
> using 
> Apache's default locale, and that Apache default's locale was "C", not
> the 
> utf8 locale configured for users. Not much of a problem for me since I
> have 
> admin access but that may not be the case with webfaction :-/

I think that should be it - my dev server runs nginx (and on my own
server I have root and anyway do not use apache.

-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread bruno desthuilliers


On Thursday, June 14, 2012 12:35:40 PM UTC+2, lawgon wrote:
>
> hi, 
>
> I have an application which runs on a webfaction hosting.



How is it deployed exactly ? 
(sorry never used webfaction hosting for django - nor for anything else 
FWIW)
 

> I also have 
> the same app running on my devel machine. The code in the two machines 
> are pulled from the same repo. Django versions are identical. Python 
> versions are identical. I try to upload a file called Lisäinfo 
> kummeille.pdf in the dev machine. No problem. When I try the same file 
> in webfaction, I get the above error. I have checked and find I can use 
> python to open and save a file of the same name from the python prompt 
> in the webfaction shell. In templates, admin and and generated pdfs, 
> these non ascii characters are handled perfectly. Has anyone got any 
> clues about this?




Each time I had this problem, it happened that the server process was using 
Apache's default locale, and that Apache default's locale was "C", not the 
utf8 locale configured for users. Not much of a problem for me since I have 
admin access but that may not be the case with webfaction :-/

HTH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/q1DkO6bIJyUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



'ascii' codec can't encode character u'\xe4'

2012-06-14 Thread kenneth gonsalves
self.exists(name):
File
"/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py" in 
exists
  230.     return os.path.exists(self.path(name))
File "/usr/local/lib/python2.7/genericpath.py" in exists
  18. os.stat(path)

Exception Type: UnicodeEncodeError at /admin/web/download/add/
Exception Value: 'ascii' codec can't encode character u'\xe4' in
position 71: ordinal not in range(128)


-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'ascii' codec can't encode character u'\xe4'

2012-04-15 Thread kenneth gonsalves
solved - I upgraded to today's trunk and the problem vanished.

On Mon, 2012-04-16 at 10:22 +0530, kenneth gonsalves wrote:
> hi,
> 
> I am doing some work in Finnish using django trunk. The code works fine
> in the shell. But on the web, I am getting a strange error. I have a
> model called Sponsor. If I give 
> 
> print item.sponsor, I get:
> Kumpumäki Raili 21755
> print item.sponsor.lname, I get:
> 'ascii' codec can't encode character u'\xe4' in position 6: ordinal not
> in range(128)
> 
> I am using postgres, and I have not seen this error in several years.
> Why does it print Kumpumäki in one case and is unable to decode it in
> the next case?
> -- 
> regards
> Kenneth Gonsalves
> 


-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



'ascii' codec can't encode character u'\xe4'

2012-04-15 Thread kenneth gonsalves
hi,

I am doing some work in Finnish using django trunk. The code works fine
in the shell. But on the web, I am getting a strange error. I have a
model called Sponsor. If I give 

print item.sponsor, I get:
Kumpumäki Raili 21755
print item.sponsor.lname, I get:
'ascii' codec can't encode character u'\xe4' in position 6: ordinal not
in range(128)

I am using postgres, and I have not seen this error in several years.
Why does it print Kumpumäki in one case and is unable to decode it in
the next case?
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: debug template tag gives me: "'ascii' codec can't encode character"

2009-01-12 Thread Flo Ledermann

Malcolm,

funny, I wanted to try the debug tag because of your tip in the
interview with '42 Topics' :)))

http://42topics.com/blog/2008/04/an-interview-with-malcolm-tredinnick/

It's not urgent on my side, just wanted to play around with it and
wondered if there is something wrong in my settings. Will open a
ticket once I am back from a meeting.

Regards,

Flo



On Jan 11, 2:22 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Sun, 2009-01-11 at 03:41 -0800, Flo Ledermann wrote:
> > Hi all,
>
> > I just bumped into a problem I can't resolve: after adding the {%
> > debug %} template tag to one of my templates (no other changes), I get
> > the following error message:
>
> > TemplateSyntaxError at /art/
>
> > Caught an exception while rendering: 'ascii' codec can't encode
> > character u'\u2019' in position 19: ordinal not in range(128)
>
> > I haven't used the debug tag before, and googleing the error message
> > didn't bring up anything useful for me, so I am turning to the group
> > for help. I paste the stack trace and a subset of my settings below.
>
> Looking at the traceback, I'm going to guess that the debug tag isn't
> handling non-ASCII characters correctly. It doesn't get used too much,
> so it may have survived all this time with such a bug in it. A bit
> embarassing (for me).
>
> If you open a ticket in Trac and assign it to me (mtredinnick), I'll
> look at it in a day or two. Not going to do it right now, since it's
> just after midnight here and I'm about to go to sleep.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: debug template tag gives me: "'ascii' codec can't encode character"

2009-01-11 Thread Malcolm Tredinnick

On Sun, 2009-01-11 at 03:41 -0800, Flo Ledermann wrote:
> Hi all,
> 
> I just bumped into a problem I can't resolve: after adding the {%
> debug %} template tag to one of my templates (no other changes), I get
> the following error message:
> 
> TemplateSyntaxError at /art/
> 
> Caught an exception while rendering: 'ascii' codec can't encode
> character u'\u2019' in position 19: ordinal not in range(128)
> 
> I haven't used the debug tag before, and googleing the error message
> didn't bring up anything useful for me, so I am turning to the group
> for help. I paste the stack trace and a subset of my settings below.

Looking at the traceback, I'm going to guess that the debug tag isn't
handling non-ASCII characters correctly. It doesn't get used too much,
so it may have survived all this time with such a bug in it. A bit
embarassing (for me).

If you open a ticket in Trac and assign it to me (mtredinnick), I'll
look at it in a day or two. Not going to do it right now, since it's
just after midnight here and I'm about to go to sleep.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: debug template tag gives me: "'ascii' codec can't encode character"

2009-01-11 Thread Flo Ledermann

Oh, I should probably add that I am using

# coding=utf-8

on some of my source files, because they contain unicode default
values etc.

Flo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



debug template tag gives me: "'ascii' codec can't encode character"

2009-01-11 Thread Flo Ledermann

Hi all,

I just bumped into a problem I can't resolve: after adding the {%
debug %} template tag to one of my templates (no other changes), I get
the following error message:

TemplateSyntaxError at /art/

Caught an exception while rendering: 'ascii' codec can't encode
character u'\u2019' in position 19: ordinal not in range(128)

I haven't used the debug tag before, and googleing the error message
didn't bring up anything useful for me, so I am turning to the group
for help. I paste the stack trace and a subset of my settings below.

Thanks in advance for any hints,

Flo Ledermann

-

Original Traceback (most recent call last):
  File "C:\lib\Python2.5.2\lib\site-packages\django\template
\debug.py", line 71, in render_node
result = node.render(context)
  File "C:\lib\Python2.5.2\lib\site-packages\django\template
\defaulttags.py", line 54, in render
output = [pformat(val) for val in context]
  File "C:\lib\Python2.5.2\lib\pprint.py", line 59, in pformat
return PrettyPrinter(indent=indent, width=width,
depth=depth).pformat(object)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 111, in pformat
self._format(object, sio, 0, 0, {}, 0)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 129, in _format
rep = self._repr(object, context, level - 1)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 195, in _repr
self._depth, level)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 207, in format
return _safe_repr(object, context, maxlevels, level)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 251, in _safe_repr
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
  File "C:\lib\Python2.5.2\lib\pprint.py", line 292, in _safe_repr
rep = repr(object)
  File "C:\lib\Python2.5.2\lib\site-packages\django\template
\loader_tags.py", line 17, in __repr__
return "" % (self.name,
self.nodelist)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in
position 19: ordinal not in range(128)


-


ABSOLUTE_URL_OVERRIDES
{}
ALLOWED_INCLUDE_ROOTS
()
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
AUTH_PROFILE_MODULE
'mainsite.Actor'
BANNED_IPS
()
CACHE_BACKEND
'locmem://'
CACHE_MIDDLEWARE_KEY_PREFIX
''
CACHE_MIDDLEWARE_SECONDS
600
COMMENTS_ALLOW_PROFANITIES
False
COMMENTS_BANNED_USERS_GROUP
None
COMMENTS_FIRST_FEW
0
COMMENTS_MODERATORS_GROUP
None
COMMENTS_SKETCHY_USERS_GROUP
None
DATABASE_ENGINE
'postgresql_psycopg2'
DATETIME_FORMAT
'N j, Y, P'
DATE_FORMAT
'N j, Y'
DEBUG
True
DEBUG_PROPAGATE_EXCEPTIONS
False
DEFAULT_CHARSET
'utf-8'
DEFAULT_CONTENT_TYPE
'text/html'
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
DEFAULT_INDEX_TABLESPACE
''
DEFAULT_TABLESPACE
''
DISALLOWED_USER_AGENTS
()
FILE_CHARSET
'utf-8'
FILE_UPLOAD_HANDLERS
('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
FILE_UPLOAD_PERMISSIONS
None
FILE_UPLOAD_TEMP_DIR
None
FIXTURE_DIRS
()
FORCE_SCRIPT_NAME
None
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico',
'.php')
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
INTERNAL_IPS
()
JING_PATH
'/usr/bin/jing'
LANGUAGES
(('ar', 'Arabic'), ('bn', 'Bengali'), ('bg', 'Bulgarian'), ('ca',
'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de',
'German'), ('el', 'Greek'), ('en', 'English'), ('es', 'Spanish'),
('et', 'Estonian'), ('es-ar', 'Argentinean Spanish'), ('eu',
'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'),
('ga', 'Irish'), ('gl', 'Galician'), ('hu', 'Hungarian'), ('he',
'Hebrew'), ('hr', 'Croatian'), ('is', 'Icelandic'), ('it', 'Italian'),
('ja', 'Japanese'), ('ka', 'Georgian'), ('ko', 'Korean'), ('km',
'Khmer'), ('kn', 'Kannada'), ('lv', 'Latvian'), ('lt', 'Lithuanian'),
('mk', 'Macedonian'), ('nl', 'Dutch'), ('no', 'Norwegian'), ('pl',
'Polish'), ('pt', 'Portugese'), ('pt-br', 'Brazilian Portuguese'),
('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl',
'Slovenian'), ('sr', 'Serbian'), ('sv', 'Swedish'), ('ta', 'Tamil'),
('te', 'Telugu'), ('tr', 'Turkish'), ('uk', 'Ukrainian'), ('zh-cn',
'Simplified Chinese'), ('zh-tw', 'Traditional Chinese'))
LANGUAGES_BIDI
('he', 'ar', 'fa')
LANGUAGE_CODE
'en-us'
LANGUAGE_COOKIE_NAME
'django_language'
LOCALE_PATHS
()
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
MONTH_DAY_FORMAT
'F j'
PASSWORD_RESET_TIMEOUT_DAYS
''
PREPEND_WWW
False
PROFANITIES_LIST
''
ROOT_URLCONF
'kunstw