Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2050 closed defect (fixed)

[patch] Display of "current value" of raw_id_admin fields wrong

Reported by: Christopher Lenz <cmlenz@…> Owned by: Adrian Holovaty
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


[2827] fixed the display of the current value of a raw_id_admin configured field in the admin app. However, what is now displayed is the ID, which doesn't seem all that helpful.

If I'm not mistaken, what should be displayed here would be the __str__ of the currently associated foreign object(s). The following patch does that by access instead of field.attname:

Index: django/contrib/admin/views/
--- django/contrib/admin/views/  (revision 510)
+++ django/contrib/admin/views/  (working copy)
@@ -143,9 +143,10 @@
             return self._display
         except AttributeError:
             if isinstance(self.field.rel, models.ManyToOneRel):
-                self._display = getattr(self.original, self.field.attname)
+                print `self.original`, `self.field.attname`
+                self._display = getattr(self.original,
             elif isinstance(self.field.rel, models.ManyToManyRel):
-                self._display = ", ".join([str(obj) for obj in getattr(self.original, self.field.attname).all()])
+                self._display = ", ".join([str(obj) for obj in getattr(self.original,])
             return self._display
     def __repr__(self):

Change History (2)

comment:1 Changed 12 years ago by Adrian Holovaty

I assume the print statement in the patch was left in erroneously, right?

comment:2 Changed 12 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [3018]) Fixed #2050 -- Fixed raw_id_admin display in admin. Thanks, Christopher Lenz

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