i have a table column as follows
actioncolumn = tables.Column(verbose_name="action",orderable=False,empty_values=[])
def render_actioncolumn(self):
edit_btn='<div>'\
'<button class="btn-info btn btn-sm btn-block" button_type="link"'\
'href="/OrganizationRegister/RefOrganizationType/"> edit </button>'\
'</div>'
delete_btn='<div>'\
'<button class="btn-danger btn btn-sm btn-block">delete</button>'\
'<div>'
return format_html('<form method="post">{{% csrf_token %}} <div class="row">' + edit_btn
+' '+ delete_btn + '</div> </form>')
the tag {% csrf_token %}
returns as plain text in my browser. The extra curlies in {{% csrf_token %}}
are there to work around the special characters i.e. "{" used in python strings. Pleased note that in the example i used {% csrf_token %} , format_html does not work with other django tags i.e.{% *** %}