Just like with ModelAdmins, we can include arbitrary python code in our inlines.
For a ModelAdmin, I often set up a python function that returns color coded html or processes data from the object somehow.
With Inlines, you might get an error that the field doesn’t exist in the form — the trick is to add the method you are adding as a readonly_field.
class OrderInline(admin.TabularInline):
model = Order
fields = ('total', 'tasting_date', '_link')
readonly_fields = ('_link', )
def _link(self, obj):
return 'hello'