Code

Opened 7 years ago

Closed 7 years ago

#4320 closed (fixed)

unicode-branch - admin select view doesn't work for localized field with choices

Reported by: anonymous Owned by: mtredinnick
Component: Internationalization Version: other branch
Severity: Keywords: unicode-branch, admin
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I have this simple model:

from django.db import models
from django.utils.translation import ugettext_lazy as _

class MyModel(models.Model):
    my_field = models.CharField(choices=(('a', _('a')), ('b', _('b'))), maxlength=1)

    class Admin:
       list_display = ['my_field']

TypeError is thrown:

TypeError at /admin/my_app/mymodel/
unicode.__cmp__(x,y) requires y to be a 'unicode', not a 'str'
Request Method: GET
Request URL: http://hradec:8003/admin/my_app/mymodel/
Exception Type: TypeError
Exception Value: unicode.__cmp__(x,y) requires y to be a 'unicode', not a 'str'
Exception Location: /usr/local/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py in items_for_result, line 184

This problem can be solved by the attached patch.

Attachments (1)

unicode-admin.diff (733 bytes) - added by anonymous 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by anonymous

comment:1 Changed 7 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from SVN to other branch

comment:2 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Unreviewed to Accepted

smart_unicode() and ugettext_lazy() don't work properly together yet (#4295). This patch will stop working once that bug is fixed. I'll fix it properly once I've worked out a solution to #4295.

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5314]) unicode: Made lazy translation objects work properly. Fixed #4295, #4320.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.