【发布时间】:2019-03-03 01:31:45
【问题描述】:
我正在尝试在 django 中使用 javascript 加载 csv 文件,但它给了我一个错误:http://127.0.0.1:8000/data.csv is not found ,data.csv 位置在带有 html 页面的模板文件夹内。
我的代码:
d3.csv("data.csv", function(d, i, columns) {
for (var i = 1, n = columns.length; i < n; ++i)
d[columns[i]] = +d[columns[i]];
return d;
}, function(error, data) {
if (error) throw error;
}
【问题讨论】:
-
http://127.0.0.1:8000/data.csv的请求中没有目录,所以它没有在模板文件夹中查找 -
怎么解决?
-
了解 Django 和 HTTP 的工作原理
-
别忘了阅读 Django 官方文档docs.djangoproject.com/en/3.1/howto/static-files