OK Thanks but I solved this little problem by adding at the top of my 
models.py:

django.utils.encoding import from python_2_unicode_compatible


And always in models.py before each class:

@ python_2_unicode_compatible

Perfect!

Le dimanche 6 mars 2016 03:16:35 UTC+1, Vijay Khemlani a écrit :
>
> The error you are seeing is at the application level, not database, so I 
> don't think postgres is at fault.
>
> Post the full stack trace for the error and the relevant part of your code 
> when it fails.
>
> On Sat, Mar 5, 2016 at 3:28 PM, Georges H <george...@gmail.com 
> <javascript:>> wrote:
>
>> Hi to all the Django community !
>>
>> I started with Django. 
>>
>> I have a small form that works pretty well, and that will store the data 
>> in a Postgres database, that's fine.
>>
>> OK, except that when I have a special character to enter (like an accent, 
>> I am french), I get an error (No problem without special characters):
>>
>> 'Ascii' codec can not encode character u '\ xe9' in position 0: ordinal 
>> not in range (128)
>>
>> Yet I thought the default Django was utf8... 
>>
>> So I tried to add in settings.py:
>>
>> LANGUAGE_CODE = 'en-us'
>> LANG = 'UTF-8'
>> LC_ALL = 'UTF-8'
>> DEFAULT_CHARSET = 'utf-8'
>>
>> But it does not change ...
>>
>> I notice that if my base postgres is encoded in UTF-8 (when I do a "SHOW 
>> SERVER_ENCODING"); the "client" is it in Unicode (when I do a "SHOW 
>> CLIENT_ENCODING"). 
>> Is it linked?
>>
>> I also notice that the "local" command at the root of my Django project 
>> returns me:
>>
>> LANG = en_US.UTF-8
>> LC_CTYPE = "en_US.UTF-8"
>> LC_NUMERIC = "en_US.UTF-8"
>> LC_TIME = "en_US.UTF-8"
>> LC_COLLATE = "en_US.UTF-8"
>> LC_MONETARY = "en_US.UTF-8"
>> LC_MESSAGES = "en_US.UTF-8"
>> LC_PAPER = "en_US.UTF-8"
>> Lc_name = "en_US.UTF-8"
>> LC_ADDRESS = "en_US.UTF-8"
>> LC_TELEPHONE = "en_US.UTF-8"
>> LC_MEASUREMENT = "en_US.UTF-8"
>> LC_IDENTIFICATION = "en_US.UTF-8"
>> LC_ALL =
>>
>> With "LC_ALL" empty !!! So it is that I did not understand where to put 
>> this setting...
>>
>> How can I force Django to operate only in UTF-8? Or another approach?
>>
>> THX!
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> 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/bd87c68d-730a-49f6-892f-bb398ed4d1b1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/bd87c68d-730a-49f6-892f-bb398ed4d1b1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/b9b18216-e21f-4195-8ae3-b3cfbed70c31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to