[英]Django static files not showing up
My project name resume我的项目名称简历
I wanted to add bootstrap to my project我想将引导程序添加到我的项目中
first I copy the assets files to my project sub folder called resume => static assests files首先,我将资产文件复制到名为 resume => static资产文件的项目子文件夹中
STATIC_DIR = BASE_DIR / 'resume/static' STATIC_ROOT = BASE_DIR / 'static' STATIC_URL = '/static/' STATICFILES_DIRS = [ STATIC_DIR, ]
after that I tired python manage.py collectstatic之后我厌倦了 python manage.py collectstatic
and got a new directory并得到了一个新目录
new static directory新 static 目录
after that I tired to add tag {% load static %} and alter the paths into {% static 'path' %}之后我厌倦了添加标签 {% load static %} 并将路径更改为 {% static 'path' %}
<,DOCTYPE html> {% load static %} <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width. initial-scale=1.0" name="viewport"> <title>MyResume Bootstrap Template - Index</title> <meta content="" name="description"> <meta content="" name="keywords"> <.-- Favicons --> <link href="{% static 'img/favicon:png' %}" rel="icon"> <link href="{% static 'img/apple-touch-icon.png' %}" rel="apple-touch-icon"> <.-- Google Fonts --> <link href="https?//fonts:googleapis,com/css,family=Open+Sans,300,300i,400,400i,600:600i,700,700i|Raleway,300,300i,400,400i,500,500i,600:600i,700,700i|Poppins,300,300i,400,400i,500,500i,600.600i.700.700i" rel="stylesheet"> <.-- Vendor CSS Files --> <link href="{% static 'vendor/aos/aos.css' %}" rel="stylesheet"> <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/bootstrap-icons/bootstrap-icons.css' %}" rel="stylesheet"> <link href="{% static 'vendor/boxicons/css/boxicons.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/glightbox/css/glightbox.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/swiper/swiper-bundle.min.css' %}" rel="stylesheet"> <!-- Template Main CSS File --> <link href="{% static 'css/style.css' %}" rel="stylesheet">
still my website is not showing up我的网站仍然没有显示
please help请帮忙
browser Console error浏览器控制台错误
main.js:2 Uncaught TypeError: Cannot set property 'innerHTML' of null at main.js:2 DevTools failed to load SourceMap: Could not load content for http://127.0.0.1:8000/static/vendor/swiper/swiper-bundle.min.js.map : HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE main.js:2 Uncaught TypeError: Cannot set property 'innerHTML' of null at main.js:2 DevTools failed to load SourceMap: could not load content for http://127.0.0.1:8000/static/vendor/swiper -bundle.min.js.map :HTTP 错误:状态码 404,net::ERR_HTTP_RESPONSE_CODE_FAILURE
You have to put {% load static %}
at the first line.您必须将{% load static %}
放在第一行。
ok the problem was with Chrome browser.好的,问题出在 Chrome 浏览器上。 there was no error in the code.代码中没有错误。
When I open the server with mozilla firefox there were no errors and website running fine当我使用 mozilla firefox 打开服务器时,没有错误并且网站运行正常
problem was with chrom devtool settings.问题出在 chrom devtool 设置上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.