【问题标题】:Bootstrap Jumbotron CSS Template is not working on Django ProjectBootstrap Jumbotron CSS 模板不适用于 Django 项目
【发布时间】:2017-03-02 17:38:33
【问题描述】:

我是 Django 项目的新手,正在尝试将 Bootstrap 应用到我的 Django 网站。

首先,让我向您展示我得到的屏幕,因为它以这种方式提供了更好的理解。这个页面是网站的“关于”(我的项目结构中的“hakkimizda”文件夹)页面,它是Django的一个平面页面。

Page result image

我的项目结构是这样的;

  • 我的项目
    • 首页
    • 我的项目
    • 静态
      • 资产
      • CSS
      • 分布
      • 图片
      • favicon.ico
    • 模板
      • 平面页面
        • 哈基米兹达
          • index.html
          • jumbotron.css

在我的 index.html 文件中,路径是这样的;

<!-- Bootstrap core CSS -->
<link href="/static/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="/static/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="/templates/flatpages/hakkimizda/jumbotron.css" rel="stylesheet">

<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="/static/assets/js/ie-emulation-modes-warning.js"></script>

Static 文件夹包含 Bootstrap 的文件。 Pages 文件夹是一个仅为平面页面创建的应用程序。

你能帮我解决这个问题吗?谢谢。

【问题讨论】:

    标签: html css django twitter-bootstrap python-3.x


    【解决方案1】:

    你跑过python manage.py collectstatic吗?

    collectstatic documentation

    【讨论】:

    • 这是开发环境
    • 在浏览器上打开您的开发工具控制台,看看您遇到了什么样的错误。它将帮助我们更多地调试您的问题。此外,最好使用static 标签来提供资产,而不是像这样对它们进行硬编码:&lt;link rel="stylesheet" href="{% static 'stylesheets/bootstrap.css' %}"&gt;。确保在您的settings.py 中正确配置了STATIC_URL
    猜你喜欢
    • 2021-03-09
    • 2018-09-19
    • 1970-01-01
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 2018-09-04
    • 1970-01-01
    相关资源
    最近更新 更多