Vous n'êtes pas identifié(e).
Bonjour,
J'ai créé un projet avec Django 1.2.5. Tout fonctionne à merveille mais lorsque j'ajoute des données qui comportent des accents en passant par l'interface d'administration Django, je reçois des erreurs de ASCII. Comment je peux rendre l'interface d'administration compatible avec UTF-8 et mes accents?
UnicodeEncodeError at /admin/home/program/add/
'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)
Request Method: POST
Request URL: http://lussier.me/admin/home/program/add/
Django Version: 1.2.5
Exception Type: UnicodeEncodeError
Exception Value:
'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)
Exception Location: /var/lib/python-support/python2.6/django/django/utils/encoding.py in force_unicode, line 69
Python Executable: /usr/bin/python
Python Version: 2.6.5
Python Path: ['/home/django', '/var/lib/python-support/python2.6/django', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages']
Server time: sam, 19 Fév 2011 15:47:08 -0500
Merci beaucoup,
Greg
Hors ligne
On Sun, Feb 20, 2011 at 1:37 PM, Dominique Guardiola <contact _AT_ quinode.fr>wrote:
En plaçant simplement en haut de tes fichiers .py :
# -*- coding:utf-8 -*-
à chaque fois que tu utilise des accents
Bonjour
je pensais avoir résolu ce type de probleme avec # -* - coding:UTF-8-*-
comme tu le preconise
Cependant a l'utilisation d'un champs de base postgres en utf-8 j'ai un
message d'erreur avec un "é"
Exception Type: UnicodeEncodeError
Exception Value:
'ascii' codec can't encode character u'\xe9' in position 44: ordinal not in
range(128)
et je n'arrive pas a m'en dépétré autrement que de changer é par e dans la
base mais je vais tomber sur un user qui me mets un accent et hop plantage
...
si quelqu 'un à une idée
j'essais avec http://docs.djangoproject.com/en/1.2/ref/unicode/ mais ça
donne rien
Tonton
Hors ligne
Alors vérifie aussi que ta base PostGreSQL a bien été créée en UTF-8
Après, pour les histoires d'encodage, j'ai une page-fétiche : http://www.stereoplex.com/blog/python-u … ecodeerror
tu pourrais aussi nous poster le code qui provoque le souci
Hors ligne