Django

Code

Ticket #2050 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: Christopher Lenz <cmlenz@gmx.de> Assigned to: adrian
Milestone: Component: Admin interface
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

[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 field.name instead of field.attname:

Index: django/contrib/admin/views/main.py
===================================================================
--- django/contrib/admin/views/main.py  (revision 510)
+++ django/contrib/admin/views/main.py  (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, self.field.name)
             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, self.field.name).all()])
             return self._display
 
     def __repr__(self):

Attachments

Change History

05/31/06 09:34:29 changed by adrian

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

05/31/06 09:37:57 changed by adrian

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

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


Add/Change #2050 ([patch] Display of "current value" of raw_id_admin fields wrong)




Change Properties
Action