【发布时间】:2018-08-29 20:48:27
【问题描述】:
我是 Django 和网络开发的新手,正在寻找有关让服务器端处理与我的数据表一起工作的指导。
基本上,我有一个包含 50 万条记录的外部 .db SQLite 文件,我想在引导数据表上显示这些记录。
在我的views.py文件中,每当他们访问index.html时,我都会做一个查询语句来获取记录(不确定这是否效率低,但这是一个小型的爱好网站)
groups = cursor.execute("""SELECT * FROM PlayerGroups""")
return render(request, 'home/index.html', {'groups': groups}) # the issue since it returns 500k records which is too much for the client to handle.
我知道我需要在“index.html”中添加这样的内容:
<script>
$(document).ready(function(){
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": <confused about this part...>
});
});
</script>
我对制作自己的数据库 API 并将 ajax 源链接到我的视图/urls 文件感到困惑。我在网上看过的所有指南都显示了带有模型和东西的服务器端处理。我只是想在数据表上显示一个外部 .db 文件。
任何指导或帮助都意义重大。
【问题讨论】:
标签: ajax django python-3.x datatable bootstrap-4