Sort, pagination and search functionality not working when I pull data from DB | Python | Django1.9
Sort, pagination and search functionality not working when I pull data from DB | Python | Django1.9
Shobin
Posts: 1Questions: 1Answers: 0
All of the features work when the Data is Raw HTML but the moment I use a For loop to extract data from the DB using Models the table is population perfectly but the above said features do not appear.
Below is my Code:
<head>
<link rel = "stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="http://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function(){
$('#example').DataTable();
});
</script>
<meta charset="UTF-8">
<title>Test</title>
</head>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td>
{{obj.title}}
</td>
<td>
{{obj.title}}
</td>
<td>
{{obj.title}}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
This discussion has been closed.