I am still having this issue.
I have in my settings DEFAULT_CHARSET = "utf-8", and I created a new
database with UTF-8 encoding (using PGAdmin).
So I go to admin page, click on my model and then the "add" button, I
include a special char (á, ç, etc) and I get a Unicode error on both,
Linux and Windows.

The error message on Linux is:

'utf8' codec can't decode bytes in position 1-2: unexpected end of
data


The error message on Windows is:

'utf8' codec can't decode bytes in position 1-3: invalid data


The problem is, it DOES saves the data and displays correctly on the
listing admin page for the model. The error only occurs when I try to
edit, on display. If the record don't have any special char, it works
correctly.


Both occurs on force_unicode procedure


When I try to add from manage.py shell onlinux (with or without
special chars), it raises an error "SET client_encoding to 'UNICODE'"
in  django/db/backends/postgresql/base.py

I really have no clue why it's happening. I just updated from svn so I
have the latest django.

Any help will be really appreciate


cheers


Anderson




On 29 ago, 18:30, Anderson Santos <[EMAIL PROTECTED]>
wrote:
> Hello,
>
> I am migrating a stable lighttpd+fcgi django app to apache+mod_python
> and I am dealing with a strange encoding behavior. Here what I did:
>
> With a plain migration from the working app to the new mod_python one
> I got a lot of LATIN1 codec errors that never occured on the last
> architecture.  So, I decided to migrate everything to UTF-8.
>
> - I had a Latin1 encoded Postgresql database. I backed it up, created
> a new one with utf-8 encoding and restored the data
> - I changed the settings to DEFAULT_CHARSET = UTF-8
>
> Now everything is fine: flatpages, admin in general, etc, except when
> I click to edit a record on admin interface it raises the error:
>
> UnicodeDecodeError at /admin/suporte/download/95/
> 'utf8' codec can't decode bytes in position 8-10: invalid data
>
> Unicode error hint
>
> The string that could not be encoded/decoded was: aliza??o de B
>
> Template error
>
> In template /srv/djprojects/django_src_trunk/django/contrib/admin/
> templates/admin/change_form.html, error at line 15
>
> Traceback (innermost last)
> Switch back to interactive view
>
>     * /srv/djprojects/django_src_trunk/django/template/__init__.py in
> render_node
>        747.
>        748. def render_node(self, node, context):
>        749. return node.render(context)
>        750.
>        751. class DebugNodeList(NodeList):
>        752. def render_node(self, node, context):
>        753. try:
>        754. result = node.render(context) ...
>        755. except TemplateSyntaxError, e:
>        756. if not hasattr(e, 'source'):
>        757. e.source = node.source
>        758. raise
>        759. except Exception, e:
>        760. from sys import exc_info
>
> Traceback (most recent call last):
> File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in
> render_node
>   754. result = node.render(context)
> File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in
> render
>   790. return self.filter_expression.resolve(context)
> File "/srv/djprojects/django_src_trunk/django/template/__init__.py" in
> resolve
>   603. obj = func(obj, *arg_vals)
> File "/srv/djprojects/django_src_trunk/django/template/
> defaultfilters.py" in _dec
>   25. args[0] = force_unicode(args[0])
> File "/srv/djprojects/django_src_trunk/django/utils/encoding.py" in
> force_unicode
>   39. s = unicode(str(s), encoding, errors)
>
>   UnicodeDecodeError at /admin/suporte/download/95/
>   'utf8' codec can't decode bytes in position 8-10: invalid data
>
> """
>
> But when displayed on admin list for the model, it displays the
> encoding correctly, even the special chars. The line in template is
> the following:
>
> <div class="breadcrumbs">
> #...
> {% if add %}{% trans "Add" %} {{ opts.verbose_name|escape }}{% else %}
> {{ original|truncatewords:"18"|escape }}{% endif %}
> #...
>
> When I click on a record that don't have special char, it works fine
> for editing, the error just occur with records with special chars.
> Again, the listing displays without problem, it seems to be a problem
> to force unicode procedure on template system.
>
> I appreciate any help.
>
> Cheers,
>
> Anderson


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to