#2050 closed defect (fixed)
[patch] Display of "current value" of raw_id_admin fields wrong
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| 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 |
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):
Change History (2)
comment:1 by , 20 years ago
comment:2 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I assume the
printstatement in the patch was left in erroneously, right?