简体   繁体   English

无法将 css 文件链接到 django

[英]can not link css file to django

This is html file where I linked the CSS file这是 html 文件,我在其中链接了 CSS 文件

{% load static %}
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>ShairuFitness</title>

    <script defer src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

    <link rel="stylesheet" type="text/css" href="{% static 'fit/css/base.css' %}">

This is settings.py file这是 settings.py 文件

STATIC_URL = '/static/'
STATICFILE_DIRS = [os.path.join(BASE_DIR,'static'),]

This is location of file这是文件的位置

static
 ->fit
   ->css
     ->base.css

ERROR错误

[10/Aug/2020 20:50:31] "GET /static/fit/css/base.css HTTP/1.1" 404 1674

Try with this settings:试试这个设置:

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

The STATIC_ROOT is used to set up the path to your static files. STATIC_ROOT用于设置 static 文件的路径。 Your can read more onthe official doc .您可以在官方文档上阅读更多内容。

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

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