I am trying to use datatables in a django application. Here is my code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> My web application </title> <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css" title="currentStyle"> @import "./DataTables-1.9.0/media/css/demo_table.css"; </style> <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> <script type="text/javascript" charset="utf-8" src="./DataTables-1.9.0/media/js/jquery.dataTables.js"></script> <script> $(document).ready( function () { $('#table_id').dataTable(); } ); </script> </head> <body> {% if success %} <form action="." method="POST"> {{ my_form.as_p }} <input type="submit" value="Send"> <input type="reset" value="Reset"> </form> <br> <table id="table_id" class="display"> <thead> <tr> {%for x in htl%} <th> {{x}} </th> {% endfor%} </tr> </thead> <tbody> {% for x in mytable %} <tr> {% for y in x %} <td> {{y}} </td> {%endfor %} </tr> {% endfor%} </tbody> </table> {% else %} <form action="." method="POST"> {{ my_form.as_p }} <input type="submit" value="Send"> <input type="reset" value="Reset"> </form> {% endif %} </body> </html> I want to pass a python list with each row as an item in the list and format the table in the template.html as is seen from the code. I couldn't get datatables working at all. Any ideas? Thanks