List Info

Thread: UnicodeEncodeError in Admin site




UnicodeEncodeError in Admin site
country flaguser name
United States
2007-03-29 18:36:16
I am using Django svn, updated 2 days ago. DEFAULT_CHARSET
is set to
'utf-8' and the files with unicode characters are all marked
-*-
coding: uft8 -*-.

When trying to view a row in one of my models in the admin
site (the
data was entered using a newforms view), I get the following
following
error:

UnicodeEncodeError at /admin/forms/foo/1/
'ascii' codec can't encode character u'xe3' in position
286: ordinal
not in range(128)

Request Method:  	GET
Request URL: 	http
://formularios.inspiro.pt/admin/forms/foo/1/
Exception Type: 	UnicodeEncodeError
Exception Value: 	'ascii' codec can't encode character
u'xe3' in
position 286: ordinal not in range(128)
Exception Location:
	/usr/lib/python2.3/site-packages/django/oldforms/
__init__.py in __str__, line 169

Template error

In template
/usr/lib/python2.3/site-packages/django/contrib/admin/
templates/widget/default.html, error at line 1

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

1 	{% load admin_modify %}{% output_all
bound_field.form_fields %}

Traceback (innermost last)

/usr/lib/python2.3/site-packages/django/template/__init__.py
in
render_node

723.	result = node.render(context)

/usr/lib/python2.3/site-packages/django/template/__init__.py
in render

856.	return func(*resolved_vars)

/usr/lib/python2.3/site-packages/django/contrib/admin/templa
tetags/
admin_modify.py in output_all

178.	return ''.join([str(f) for f in form_fields])

/usr/lib/python2.3/site-packages/django/oldforms/__init__.py
in
__str__

169.	return str(self.formfield.render(self.data))

Now, to correct the problem, I went and swapped 'str' out
for
'unicode' in the last two lines of the traceback. This
solves the
problem, but creates another. If one tries to save a
flatpage
containing accented characters, the same error is reproduced
on those
two lines that were altered when rendering the following
view, though
the page will be saved.

Any suggestions?


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


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )