【问题标题】:Django: CSS Background image not working after updateDjango:CSS背景图像在更新后不起作用
【发布时间】:2017-05-18 15:19:57
【问题描述】:

我刚刚将我的 Django 1.10 (Python 3.5) 应用升级到 Django 1.11 (Python 3.6)。大多数事情仍然有效,但由于某种原因,我的 CSS 背景图像不再被渲染(我尝试使用旧版本,它仍然可以在那里工作)。这只发生在 CSS 上,当它是 HTML 标记时仍然正常加载。

这是我第一次处理我的 Django 应用程序的更新,所以我不太确定处理这些小问题的正确方法是什么。

我一直在为背景图片尝试不同的方法,但都没有奏效。

这是我失败的代码,

{% extends 'base.html' %}
{% load staticfiles %}

{% block style %}
<style>

#top {
    /*background: url("{% static 'img/skyscraper.jpg' %}") no-repeat center center fixed;*/
    background: url("/static/img/skyscraper.jpg");
    /*background: url('{{ STATIC_URL }}img/skyscraper.jpg');*/
    background-attachment: scroll;
    background-size: cover;
    min-height: 700px;
}

</style>
{% endblock %}

【问题讨论】:

    标签: python css django upgrade


    【解决方案1】:

    你需要执行python manage.py collectstatic

    【讨论】:

    • 我尝试并意识到问题可能出在 python 3.6 上。根据 python 3.6 的自述文件,SSL 连接发生了一些变化。我会提出一个关于它的新问题。谢谢。
    • 到目前为止,问题似乎是由 Python 3.6 和我使用 AWS S3 的事实引起的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2018-05-08
    • 2016-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多