#8487 closed (worksforme)
short_description doesn't work with international characters
Reported by: | helgiborg | Owned by: | Charlie La Mothe |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | aug22sprint | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The following short_description will not show up in the admin interface.
class Comment(models.Model): text = models.TextField(core=True) time = models.DateTimeField(auto_now=True) def commentTime(obj): return obj.time commentTime.short_description = "Tími"
However, if I change it to the following, it will work correctly:
commentTime.short_description = "Timi"
Attachments (1)
Change History (7)
comment:1 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
It is perfectly valid in Django to use UTF-8 strings, so this is a legitimate bug. What should be happening is where the short description is output (in the admin), it needs to be passed through force_unicode()
.
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
comment:4 by , 16 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I am unable to reproduce a situation where a method's short_description is hidden in the admin changelist view due to international characters.
When I first set ( my_method.short_description = "Tími"
), python threw an error upon runserver:
SyntaxError: Non-ASCII character '\xc3' in file .../models.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
Following the PEP referred to in the error, I fixed this error by inserting the following at the top of my models.py:
# coding=utf-8
I haven't had any issues since I inserted that line.
I will attach tests, although they're probably a mute point since the issue that the ticket raises is invalid.
comment:5 by , 16 years ago
Keywords: | aug22sprint added |
---|
You most likely have to use an unicode string (
commentTime.short_description = u"Tími"
) and set your file encoding properly.