在Jquery DataTable中为我的Django应用程序搜索和排序,PostgreSQL数据库不工作

2024-10-02 12:24:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Jquery DataTable,并在我的Django应用程序中从PostgreSQL数据库获取数据。我可以将数据放入表中,但无法对表进行排序和搜索

datatables.js

// Call the dataTables jQuery plugin
$(document).ready(function() {
  $('#dataTable').DataTable();
});

index.html

<div class="card-body">
  <div class="table-responsive">
    <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
    <thead>
        <tr>
          <th>Testing Type</th>
          <th>Question</th>
          <th>Difficulty Level</th>
        </tr>
   </thead>
   {% for qiq in qa_interview_questions %}
   <tbody>
     <tr>
        <td>{{ qiq.testingtype }}</td>
        <td>{{ qiq.question }}</td>
        <td>{{ qiq.difficultylevel }}</td>
      </tr>
    </tbody>
  {% endfor %}
  </table>
</div>
</div>

不知何故,DataTable中的搜索和排序根本不起作用。如果我对数据进行硬处理,它就会起作用。 我做错了什么


Tags: 数据djangodiv排序tablejquerytrclass

热门问题