Opened 16 years ago

Closed 16 years ago

Last modified 13 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: 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)

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

Download all attachments as: .zip

Change History (7)

comment:1 by Julian Bez, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

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 by Charlie La Mothe, 16 years ago

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

comment:4 by Charlie La Mothe, 16 years ago

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 .../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 Charlie La Mothe, 16 years ago

Keywords: aug22sprint added

by Charlie La Mothe, 16 years ago

Attachment: t8487_r8471_tests.diff added

Tests for revision 8471

comment:6 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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