【问题标题】:bootstrap css not loading in django template引导 css 未在 django 模板中加载
【发布时间】:2019-08-21 07:23:48
【问题描述】:

加载 base_html 时,所有引导 css 正在加载:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
     <!-- Custom styles for this template -->
     <link rel="stylesheet" href="{% static "artdb/css/custom.css" %}">

但是当我想加载我的登录页面时,没有加载 css:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<!-- Custom styles for this template -->
<link hrel="stylesheet" href="{% static "artdb/css/signin.css" %}">

我的 urls.py:

path('',TemplateView.as_view(template_name='artdb/base.html')),
path('signin/',TemplateView.as_view(template_name='artdb/signin.html')),

有什么想法吗?

我在两个文件中都有 {% load staticfiles %}。有任何想法吗?

【问题讨论】:

  • 应该是{% load static %} 而不是{% load staticfiles %}

标签: python css django bootstrap-4


【解决方案1】:

在您的登录页面中,将自定义样式引用从 hrel 更改为 rel

<link rel="stylesheet" href="{% static "artdb/css/signin.css" %}">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-12
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 2021-02-09
    • 1970-01-01
    相关资源
    最近更新 更多