5👍
✅
The correct way is to set a boolean
attribute on the method itself. You should also make sure the method always returns a bool.
def image_tag(self):
return bool(self.main_image)
image_tag.boolean = True
(This is documented, but there’s no way to link to the exact place: see about halfway through the list_display
section.)
Source:stackexchange.com