Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#1054 closed defect (fixed)

[magic-removal][patch] Change lists in new-admin still use __repr__() instead of __str__()

Reported by: GomoX <gomo@…> Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: gomo@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Although [1042] removed pretty much every use of __repr__() where __str__() should have been in place, the change lists in the admin (i.e, when you click on a pluralized model name in the main admin screen, and get a list of the corresponding objects) looks like it's still using __repr__(). I looked in the admin code but I couldn't find the corresponding call or %r appearance.

Attachments (2)

magic_removal-admin_list_repr_to_str.diff (1.4 KB) - added by Tom Tobin <korpios@…> 10 years ago.
Fix admin_list using __repr__ where it should use __str__
magic_removal-admin_list_repr_to_str-2.diff (1.4 KB) - added by Tom Tobin <korpios@…> 10 years ago.
Fix admin_list using __repr__ where it should use __str__ (fresh for recent changes)

Download all attachments as: .zip

Change History (9)

comment:1 Changed 10 years ago by GomoX <gomo@…>

  • Summary changed from Change lists in new-admin still use !__repr!__() instead of !__str!__() to Change lists in new-admin still use __repr__() instead of __str__()

comment:2 Changed 10 years ago by anonymous

Are you sure that you not just have a repr in your list_fields? Happened to me after the change: I forgot to change my repr listings in the list_fields to better fields (or to str), so the repr was still called and of course nothing showed in the view, as everything was angular brackets ...

comment:3 Changed 10 years ago by GomoX <gomo@…>

No, I actually set both __repr__() and __str__() to something unambigous so that I could tell one from the other. The only place in the admin where __repr__() is still used is the change lists, as far as i've seen.
This bug is also obscured by the default python fallback behaviour described in #710.

comment:4 Changed 10 years ago by bruce@…

Does the patch from ticket:889 help here?

comment:5 Changed 10 years ago by Tom Tobin <korpios@…>

  • Summary changed from Change lists in new-admin still use __repr__() instead of __str__() to [magic-removal][patch] Change lists in new-admin still use __repr__() instead of __str__()

Attaching a patch against magic-removal to fix this issue.

Changed 10 years ago by Tom Tobin <korpios@…>

Fix admin_list using __repr__ where it should use __str__

Changed 10 years ago by Tom Tobin <korpios@…>

Fix admin_list using __repr__ where it should use __str__ (fresh for recent changes)

comment:6 Changed 10 years ago by Tom Tobin <korpios@…>

Added a fresh patch to take into account recent changes (basically just shifted lines), as it came up as a conflict after a recent svn up on my end.

comment:7 Changed 10 years ago by adrian

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

(In [2340]) magic-removal: Fixed #1054 -- Changed admin changelist to use str(), not repr()

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