Opened 17 years ago

Closed 16 years ago

#4641 closed (fixed)

newforms-admin: fix for displaying field str() value next to raw_id fields

Reported by: Matthew Flanagan <mattimustang@…> Owned by: xian
Component: contrib.admin Version: newforms-admin
Severity: Keywords: nfa-blocker
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi, here's a simple fix so that newforms-admin displays the current str() representation of a field next to its raw_id input widget.

regards

matthew

Index: django/contrib/admin/widgets.py
===================================================================
--- django/contrib/admin/widgets.py     (revision 5505)
+++ django/contrib/admin/widgets.py     (working copy)
@@ -65,9 +65,9 @@
         output.append('<a href="%s%s" class="related-lookup" id="lookup_id_%s" onclick="return showRelatedObjectLookupPopup(this);"> ' % \
             (related_url, url, name))
         output.append('<img src="%simg/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>' % settings.ADMIN_MEDIA_PREFIX)
+        if value:
+            output.append('&nbsp;<strong>%s</strong>' % self.rel.to.objects.get(id=value))
         return u''.join(output)
-        #if self.change: # TODO
-            #output.append('&nbsp;<strong>TODO</strong>')

 class RelatedFieldWidgetWrapper(object):
     """

Attachments (3)

4641.diff (790 bytes ) - added by Karen Tracey <kmtracey@…> 16 years ago.
This patch also works for the case where the primary key field is not named 'id'
r6898_fk_raw_id_fix.diff (893 bytes ) - added by Brian Rosner 16 years ago.
same patch karen provided, plus removing the TODO that this fixes. not trying to be picky ;)
4641_raw_admin_fields_display_fix.diff (3.2 KB ) - added by Brian Rosner 16 years ago.
more than likely the final patch to be committed. posted here to get some last minute feedback.

Download all attachments as: .zip

Change History (7)

comment:1 by jkocherhans, 17 years ago

Owner: changed from nobody to xian
Triage Stage: UnreviewedAccepted

by Karen Tracey <kmtracey@…>, 16 years ago

Attachment: 4641.diff added

This patch also works for the case where the primary key field is not named 'id'

comment:2 by Brian Rosner, 16 years ago

Keywords: nfa-blocker added

by Brian Rosner, 16 years ago

Attachment: r6898_fk_raw_id_fix.diff added

same patch karen provided, plus removing the TODO that this fixes. not trying to be picky ;)

comment:3 by Brian Rosner, 16 years ago

Triage Stage: AcceptedReady for checkin

by Brian Rosner, 16 years ago

more than likely the final patch to be committed. posted here to get some last minute feedback.

comment:4 by Brian Rosner, 16 years ago

Resolution: fixed
Status: newclosed

(In [7177]) newforms-admin: Fixed #4641. ForeignKeyRawIdWidget now properly displays the related object value. Thanks, Matthew Flanagan for the original patch.

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