Django

Code

Ticket #4320 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: anonymous Assigned to: mtredinnick
Milestone: Component: Internationalization
Version: other branch Keywords: unicode-branch, admin
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

unicode-admin.diff (0.7 kB) - added by anonymous on 05/16/07 21:40:03.

Change History

05/16/07 21:40:03 changed by anonymous

  • attachment unicode-admin.diff added.

05/16/07 21:42:54 changed by anonymous

  • needs_better_patch changed.
  • version changed from SVN to other branch.
  • needs_tests changed.
  • needs_docs changed.

05/17/07 10:56:44 changed by mtredinnick

  • 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.

05/22/07 03:06:57 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #4320 (unicode-branch - admin select view doesn't work for localized field with choices)




Change Properties
Action