Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Getting Access to Object in Admin Panel

27 views
Skip to first unread message

That guy

unread,
Dec 29, 2012, 6:17:19 PM12/29/12
to django...@googlegroups.com
After overriding list_display, I noticed that I lost access to being able to directly click on the object to view all its fields in the control panel. Hence, I needed to resort to defining return_unicode. I know that theres definitely a better way to approach it, so whats the 'Django' way of doing this?

def return_unicode(obj):
    return obj.__unicode__()

class PictureAdmin(admin.ModelAdmin):
    list_display = (return_unicode,'uploader','image','rated','approved',)

Thank You ahead of time.

donarb

unread,
Dec 30, 2012, 2:47:05 AM12/30/12
to django...@googlegroups.com
You can code a string that references the __unicode__ method:

list_display = ('__unicode__', ...

Amirouche

unread,
Dec 30, 2012, 12:02:37 PM12/30/12
to django...@googlegroups.com


On Sunday, December 30, 2012 8:47:05 AM UTC+1, donarb wrote:
You can code a string that references the __unicode__ method:

  list_display = ('__unicode__', ...

Daniel Roseman

unread,
Jan 1, 2013, 6:06:55 AM1/1/13
to django...@googlegroups.com
Others have given you the answer, bit note that the correct way to call an object's __unicode__ method is to do ` unicode(obj)`. As a general rule, you should never call the double- underscore methods directly.
Reply all
Reply to author
Forward
0 new messages