Opened 18 years ago

Closed 17 years ago

#4320 closed (fixed)

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

Reported by: anonymous Owned by: Malcolm Tredinnick
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: no UI/UX: no

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 18 years ago.

Download all attachments as: .zip

Change History (4)

by anonymous, 18 years ago

Attachment: unicode-admin.diff added

comment:1 by anonymous, 18 years ago

Version: SVNother branch

comment:2 by Malcolm Tredinnick, 18 years ago

Triage Stage: UnreviewedAccepted

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

Resolution: fixed
Status: newclosed

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

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