2👍
✅
You can simply try this
class TransactionAdmin(admin.ModelAdmin):
readonly_fields = ('order_details')
def form_url(self, id):
url = reverse("admin:reverse_url", args=[id])
return '<a href=%s>%s</a>'%(url, id)
def order_details(self, obj):
return "<br>".join([self.form_url(k.id) for k in obj.orderdetail_set.all()])
order_details.allow_tags=True
form_url.allow_tags=True
Source:stackexchange.com