如何解决静态文件未收集在名为资产的根文件夹中
与该问题相关的所有文件的GitHub存储库:-click here
更新 静态文件未收集到STATIC_ROOT文件夹中
我更改了Django框架的基本目录(telusko)的设置,并在{%load static%}
中添加了index.html
,但是chrome的控制台也显示了:>
GET http://127.0.0.1:8000/static/plugins/OwlCarousel2-2.2.1/owl.carousel.css
net::ERR_ABORTED 404 (Not Found)
{p {1}}的代码段;
setting.py
包含所有HTML,CSS,js文件,我已经通过cmd sitetravello
为所有静态文件创建了资产。
python manage.py collectstatic
# Static files (CSS,JavaScript,Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
STATICFILILE_DIRS = [
os.path.join(BASE_DIR,'sitetravello')
]
STATIC_ROOT = os.path.join(BASE_DIR,'assets')
的主要文件代码为:
index.html
色度错误:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Travello</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Travello template project">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css" href="{% static 'styles/bootstrap4/bootstrap.min.css' %}">
<link href="{% static 'plugins/font-awesome-4.7.0/css/font-awesome.min.css' %}" rel="stylesheet" type="text/css">
铬色控制台错误:
Failed to load resource: the server response with the status of 404(not found)
解决方法
您的STATIC_ROOT
设置为查找名为assets
的文件夹。确保将plugins/OwlCarousel2-2.2.1/owl.carousel.css
放在名为assets
的文件夹中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。