0

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/"> &nbsp; edit &nbsp;</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 
                 +'&nbsp;'+ 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.{% *** %}

ritchie
  • 1
  • 2

1 Answers1

0

instead of using format_html() to run the html , i read up on a template column, just moved all the html into a template and all was well. Now i have a Django-Tables2 Table with a edit and delete button side by side.

ritchie
  • 1
  • 2