在 Jquery DataTable 中为我的 Django 应用程序搜索和排序,PostgreSQL DB 不起作用

问题描述

我正在使用 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 中的搜索和排序根本不起作用。如果我对数据进行硬核,它会起作用。 我在这里做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)