Django статические файлы - Не удалось загрузить ресурс сетевое соединение было потеряно
Я работаю над проектом Django, в котором я пытаюсь обслуживать статические файлы, помещая все статические файлы в каталог STATICFILES_DIRS. Структура статических директорий выглядит следующим образом:
static/css: bootstrap-theme.min.css bootstrap.min.css
daterangepicker.css font-awesome.min.css
jquery.dataTables.min.cssstatic/images: sort_asc.png sort_asc_disabled.png
>
sort_both.png sort_desc.png sort_desc_disabled.pngstatic/js: Chart.min.js daterangepicker.min.js
. jquery.min.js moment.min.js bootstrap.min.js
jquery.dataTables.min.js jsapi
popper.min.jsstatic/webfonts: fa-brands-400.eot fa-brands-400.ttf
fa-brands-400.woff2 fa-regular-400.svg fa-regular-400.woff
fa-solid-900.eot fa-solid-900.ttf fa-solid-900.woff2 fa-brands-400.svg fa-brands-400.woff fa-regular-400.eot
fa-regular-400.ttf fa-regular-400.woff2 fa-solid-900.svg
fa-solid-900.woff
settings.py:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static/'),
]
urls.py
urlpatterns += staticfiles_urlpatterns()
Включая статические файлы, как показано ниже:
{% load static %}
<script src="{% static 'js/jsapi' %}"></script>
<script src="{% static 'js/jquery.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/moment.min.js' %}"></script>
<script src="{% static 'js/daterangepicker.min.js' %}"></script>
<script src="{% static 'js/Chart.min.js' %}"></script>
<script src="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'application1/jquery.cookie.js' %}"></script>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}" />
<link rel="stylesheet" href="{% static 'css/bootstrap-theme.min.css' %}" />
<link rel="stylesheet" href="{% static 'css/daterangepicker.css' %}" />
<link rel="stylesheet" href="{% static 'css/font-awesome.min.css' %}" />
<link rel="stylesheet" href="{% static 'css/jquery.dataTables.min.css' %}" />
<link rel="stylesheet" href="{% static 'application1/style.css' %}"/>
Вышеуказанные ошибки непосредственно приводят к:
[Warning] jQuery.Deferred exception: $('#table').DataTable is not a function. (In '$('#table').DataTable({"paging": true})', '$('#table').DataTable' is undefined) (2) (jquery.min.js, line 2)
"http://127.0.0.1:3000/:1771:45
j@http://127.0.0.1:3000/static/js/jquery.min.js:2:30004
http://127.0.0.1:3000/static/js/jquery.min.js:2:30314"
undefined
[Error] TypeError: $('#table').DataTable is not a function. (In '$('#table').DataTable({"paging": true})', '$('#table').DataTable' is undefined)
(anonymous function) (jquery.min.js:2:31697)
Эти ошибки не всегда воспроизводимы, иногда все работает нормально, поэтому проблема не должна быть связана со статическим путем к файлу и механизмом обслуживания. Пожалуйста, помогите мне понять, что здесь может идти не так?