繁体   English   中英

Django static 文件未显示

[英]Django static files not showing up

我的项目名称简历

我想将引导程序添加到我的项目中

首先,我将资产文件复制到名为 resume => static资产文件的项目子文件夹中

    - 恢复->恢复/静态
然后我在setting.py中添加以下设置
STATIC_DIR = BASE_DIR / 'resume/static' STATIC_ROOT = BASE_DIR / 'static' STATIC_URL = '/static/' STATICFILES_DIRS = [ STATIC_DIR, ]

之后我厌倦了 python manage.py collectstatic

并得到了一个新目录

新 static 目录

之后我厌倦了添加标签 {% 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">

indext.html

我的网站仍然没有显示

网站图片

请帮忙

浏览器控制台错误

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

您必须将{% load static %}放在第一行。

好的,问题出在 Chrome 浏览器上。 代码中没有错误。
当我使用 mozilla firefox 打开服务器时,没有错误并且网站运行正常

问题出在 chrom devtool 设置上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM