Opened 7 years ago

Closed 7 years ago

Last modified 3 years ago

#8487 closed (worksforme)

short_description doesn't work with international characters

Reported by: helgiborg Owned by: clamothe
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: UI/UX:

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 clamothe 7 years ago.
Tests for revision 8471

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by julianb

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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

comment:2 Changed 7 years ago by mtredinnick

  • Resolution invalid deleted
  • Status changed from closed to 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 Changed 7 years ago by clamothe

  • Owner changed from nobody to clamothe
  • Status changed from reopened to new

comment:4 Changed 7 years ago by clamothe

  • Resolution set to worksforme
  • Status changed from new to 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 Changed 7 years ago by clamothe

  • Keywords aug22sprint added

Changed 7 years ago by clamothe

Tests for revision 8471

comment:6 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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