关于错误failed to load resource/ the server responded with a status of 404 (not found)

​ 今天在项目中报了一个错误Failed to load resource: the server responded with a status of 404 (Not Found),错误的原因找了很久没找到,各方面都检查了一遍

  • 起初以为是<script src="..."></script>中没有加type引起的,但是加上之后还是有问题
  • 后来以为是在src中的路径有错误,从绝对路径和相对路径两个方面都配置了一遍还是不行
  • 最后发现是,Django的setting文件中因为粗心导致STATICFILES_DIRS写成了STATICFILES_DIR所以文件导入不成功
1
2
3
4
5
6
7
STATICFILES_DIR = [
os.path.join(BASE_DIR, "static")
]

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
]