I have a TabularInline admin layout, all works fine except I'd like to have it show something other than the Obj.__unicode__
value on the top left of each row.
My TabularInline is a photologue ImageModel model, so I'd like it to show me the thumbnail instead of the regular __unicode__
result.
I tried to change __unicode__
to output the thumbnail, which works, except the HTML is escaped so I get <img src="XXX"...... etc
Is there an easy way to mark my __unicode__
method as a safe string? Or a way to override the property the admin chooses to display?
I've tried this:
__unicode__.is_safe = True
But that doesn't work.
You can customize the template for you TabularInline to make it look the way you want. I think it's a better idea then hacking __unicode__
:
class PhotoInline(admin.TabularInline):
model = Photo
template = 'photologue/photoinline.html'
The easiest way to create your is to copy and customize the default django/contrib/admin/templates/admin/edit_inline/tabular.html
template.