首页 > 解决方案 > 添加 CSS 文件后出现黑屏

问题描述

所以我正在关注来自https://simpleisbetterthancomplex.com/series/2017/09/11/a-complete-beginners-guide-to-django-part-2.html#figure-5的 python django 教程

已下载 Bootstrap 编译的 CSS 和 JS 版本(Bootstrap v4.0.0)。但是当我在 cmd 提示符上运行它时。它只显示空白屏幕,但是当我删除 css 文件时,它显示基本的 HTML 页面。我认为链接我的 css 文件时存在一些问题。

目录看起来像

myproject/
 |-- myproject/
 |    |-- boards/
 |    |-- myproject/
 |    |-- templates/
 |    |-- static/
 |    |    +-- css/
 |    |         +-- bootstrap.min.css.map    <-- here
 |    +-- manage.py
 +-- venv/

DEBUG 为真,安装了 django.contrib.staticfiles

我的 settings.py 文件代码看起来像

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

Home.html 文件看起来像

{% load static %}<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Boards</title>
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
  </head>
  <body>
    <!-- body suppressed for brevity ... -->
  </body>
</html>

请帮忙!

标签: pythoncssdjango

解决方案


推荐阅读