静态文件未收集在名为资产的根文件夹中

问题描述

与该问题相关的所有文件的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的文件夹中。