#12892: UnicodeEncodeError in contrib.admindocs with non-EN locale
-------------------------------------------+--------------------------------
Reporter: Beuc | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: 1.1
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Old description:
> I have this in my urls.py:
> (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> and this in my settings.py:
> LANGUAGE_CODE = 'fr'
> # (same with 'fr-fr')
>
> If I go to http://localhost:8000/admin/doc/models/auth.user/
>
> I get:
> Unicode error hint
>
> The string that could not be encoded/decoded was: <modèle :u
>
> Environment:
>
> Request Method: GET
> Request URL: http://localhost:8000/admin/doc/models/auth.user/
> Django Version: 1.1.1
> Python Version: 2.5.5
> Installed Applications:
> ['django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.admin',
> 'django.contrib.admindocs',
> 'test421']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'test421.middleware.requirelogin.RequireLoginMiddleware')
>
> Traceback:
> File "/usr/lib/pymodules/python2.5/django/core/handlers/base.py" in
> get_response
> 92. response = callback(request, *callback_args,
> **callback_kwargs)
> File
> "/usr/lib/pymodules/python2.5/django/contrib/admin/views/decorators.py"
> in _checklogin
> 33. return view_func(request, *args, **kwargs)
> File "/usr/lib/pymodules/python2.5/django/contrib/admindocs/views.py" in
> model_detail
> 228. 'verbose': utils.parse_rst(_("all %s") % verbose ,
> 'model', _('model:') + opts.module_name),
> File "/usr/lib/pymodules/python2.5/django/contrib/admindocs/utils.py" in
> parse_rst
> 70. settings_overrides=overrides)
> File "/usr/lib/pymodules/python2.5/docutils/core.py" in publish_parts
> 432. enable_exit_status=enable_exit_status)
> File "/usr/lib/pymodules/python2.5/docutils/core.py" in
> publish_programmatically
> 646. output = pub.publish(enable_exit_status=enable_exit_status)
> File "/usr/lib/pymodules/python2.5/docutils/core.py" in publish
> 203. self.settings)
> File "/usr/lib/pymodules/python2.5/docutils/readers/__init__.py" in read
> 69. self.parse()
> File "/usr/lib/pymodules/python2.5/docutils/readers/__init__.py" in parse
> 74. self.document = document = self.new_document()
> File "/usr/lib/pymodules/python2.5/docutils/readers/__init__.py" in
> new_document
> 80. document = utils.new_document(self.source.source_path,
> self.settings)
> File "/usr/lib/pymodules/python2.5/docutils/utils.py" in new_document
> 426. source_path = decode_path(source_path)
> File "/usr/lib/pymodules/python2.5/docutils/utils.py" in decode_path
> 340. path = path.decode(sys.getfilesystemencoding(), 'strict')
> File "/usr/lib/python2.5/encodings/utf_8.py" in decode
> 16. return codecs.utf_8_decode(input, errors, True)
>
> Exception Type: UnicodeEncodeError at /admin/doc/models/auth.user/
> Exception Value: 'ascii' codec can't encode character u'\xe8' in position
> 4: ordinal not in range(128)
>
> If I switch to:
> LANGUAGE_CODE='en-US'
>
> the problem disappears.
>
> It looks like the translated string is not properly declared as Unicode.
New description:
I have this in my urls.py:
{{{
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
}}}
and this in my settings.py:
{{{
LANGUAGE_CODE = 'fr'
# (same with 'fr-fr')
}}}
If I go to http://localhost:8000/admin/doc/models/auth.user/
I get:
{{{
Unicode error hint
The string that could not be encoded/decoded was: <modèle :u
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/doc/models/auth.user/
Django Version: 1.1.1
Python Version: 2.5.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.admindocs',
'test421']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'test421.middleware.requirelogin.RequireLoginMiddleware')
Traceback:
File "/usr/lib/pymodules/python2.5/django/core/handlers/base.py" in
get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File
"/usr/lib/pymodules/python2.5/django/contrib/admin/views/decorators.py" in
_checklogin
33. return view_func(request, *args, **kwargs)
File "/usr/lib/pymodules/python2.5/django/contrib/admindocs/views.py" in
model_detail
228. 'verbose': utils.parse_rst(_("all %s") % verbose ,
'model', _('model:') + opts.module_name),
File "/usr/lib/pymodules/python2.5/django/contrib/admindocs/utils.py" in
parse_rst
70. settings_overrides=overrides)
File "/usr/lib/pymodules/python2.5/docutils/core.py" in publish_parts
432. enable_exit_status=enable_exit_status)
File "/usr/lib/pymodules/python2.5/docutils/core.py" in
publish_programmatically
646. output = pub.publish(enable_exit_status=enable_exit_status)
File "/usr/lib/pymodules/python2.5/docutils/core.py" in publish
203. self.settings)
File "/usr/lib/pymodules/python2.5/docutils/readers/__init__.py" in read
69. self.parse()
File "/usr/lib/pymodules/python2.5/docutils/readers/__init__.py" in parse
74. self.document = document = self.new_document()
File "/usr/lib/pymodules/python2.5/docutils/readers/__init__.py" in
new_document
80. document = utils.new_document(self.source.source_path,
self.settings)
File "/usr/lib/pymodules/python2.5/docutils/utils.py" in new_document
426. source_path = decode_path(source_path)
File "/usr/lib/pymodules/python2.5/docutils/utils.py" in decode_path
340. path = path.decode(sys.getfilesystemencoding(), 'strict')
File "/usr/lib/python2.5/encodings/utf_8.py" in decode
16. return codecs.utf_8_decode(input, errors, True)
Exception Type: UnicodeEncodeError at /admin/doc/models/auth.user/
Exception Value: 'ascii' codec can't encode character u'\xe8' in position
4: ordinal not in range(128)
}}}
If I switch to:
{{{
LANGUAGE_CODE='en-US'
}}}
the problem disappears.
It looks like the translated string is not properly declared as Unicode.
Comment (by ramiro):
Re-formated description. Please use preview (and WikiFormatting for
complex descriptions) as suggested in the notes displayed before you open
a ticket.
--
Ticket URL: <http://code.djangoproject.com/ticket/12892#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.