Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#8487 closed (worksforme)

short_description doesn't work with international characters

Reported by: helgiborg Owned by: Charlie La Mothe
Component: contrib.admin Version: master
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


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)

t8487_r8471_tests.diff (2.0 KB) - added by Charlie La Mothe 10 years ago.
Tests for revision 8471

Download all attachments as: .zip

Change History (7)

comment:1 Changed 10 years ago by Julian Bez

Resolution: invalid
Status: newclosed

You most likely have to use an unicode string (commentTime.short_description = u"Tími") and set your file encoding properly.

comment:2 Changed 10 years ago by Malcolm Tredinnick

Resolution: invalid
Status: closedreopened

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 Changed 10 years ago by Charlie La Mothe

Owner: changed from nobody to Charlie La Mothe
Status: reopenednew

comment:4 Changed 10 years ago by Charlie La Mothe

Resolution: worksforme
Status: newclosed

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 .../ on line 8, but no encoding declared; see for details

Following the PEP referred to in the error, I fixed this error by inserting the following at the top of my

# 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 Changed 10 years ago by Charlie La Mothe

Keywords: aug22sprint added

Changed 10 years ago by Charlie La Mothe

Attachment: t8487_r8471_tests.diff added

Tests for revision 8471

comment:6 Changed 7 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top