簡體   English   中英

如何關閉 static 文件的自動更新? 在 django (python)

[英]How do I turn off auto-update on static files? in django (python)

我想更改 css。 當我更改 oncklick function 的 continer 高度時,1 秒后返回相同的大小,並且當我在 1 秒內出現錯誤控制台刷新並且我看不到時。 如何修復? 我關閉 livereload 插件。它會在 1 秒內刷新所有內容。

當我在 css 崩潰后將 {% now "U" %} 刪除到 css 鏈接 rel 並且不起作用時,為什么? 這是問題嗎?

這是我的代碼--->

底座.html

<!DOCTYPE HTML>

<html>
<head>
    <title>home</title>
</head>

<link rel="stylesheet" type="text/css" href="/static/css/style.css?{% now "U" %}" />


<body>


{% block content %}
{% endblock %}

<script src="/static/js/homescript.js"></script>
</body>
</html>

主頁.html

{% extends 'base.html' %}
<link rel="stylesheet" type="text/css" href="/static/css/style.css?{% now "U" %}" />

{% block content %}

    <form action = '' method="post" novalidate="novalidate">
        {% csrf_token %}
        <div class="continer">
        {% for field in form %}
        {{ field.label_tag }}
        {{ field }}
        {{ field.errors }}
        {% endfor %}
        <input type="submit" name="register" id="btn" onClick = "document.querySelector('#continer').style.height = '200px';">
        </div>
    </form>

{% endblock %}

樣式.css

@import url("//cdn.web-fonts.ge/fonts/bpg-glaho-arial/css/bpg-glaho-arial.min.css");

html,body{
    background-image: url("../img/test.jpg") ;
    background-position: center center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-attachment: fixed;
    padding: 0;
    margin: 0;
}

.continer {
    position: absolute;
    width: 300px;
    height:400px;
    background-color: blue;
}

.inp{
    margin: 3px;
    margin-left: 57px;
    width: 180px;
    height: 20px;
    border-radius: 5px;
    border: none;
    outline: none;

}

input,label {
    display:block;
    font-family: "BPG Glaho Arial", sans-serif;
    text-align: center;

}

.btn{
    margin-bottom: 20px;
}

.errorlist{
    background-color: red;
    border-radius: 2px;
    width: 220px;
    list-style-type: none;
    margin-left: 20px;
    color:white;
    text-align: center;

}
.errorlist li{
    padding-right: 28px;
    font-family: "BPG Glaho Arial", sans-serif;

}

將鏈接標簽放在base.html的head標簽中

去掉 home.html 中的這一行

<link rel="stylesheet" type="text/css" href="/static/css/style.css?{% now "U" %}" />

最重要的是,在 home.html 的這一行中:

<input type="submit" name="register" id="btn" onClick = "document.querySelector('#continer').style.height = '200px';">

它不是

#container

這是

.container

class 名稱可以通過 (.) 訪問,id 名稱可以通過 (#) 訪問

所以將該行替換為:

<input type="submit" name="register" id="btn" onClick = "document.querySelector('.continer').style.height = '200px';">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM