簡體   English   中英

為什么我會收到無效的塊標記:“靜態”錯誤?

[英]why would I be getting Invalid block tag: 'static' error?

這是我的base.html的標題:

{% load staticfiles %}

<head>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />    
<!-- the CSS for Foundation - Base of client side -->
<link rel="stylesheet" href="{% static 'css/foundation.css' %}" />

<!-- the CSS for Smooth Div Scroll -->
<link rel="Stylesheet" type="text/cs' %}" href="{% static 'top_scroll/css/smoothDivScroll.css' %}" />

<!-- the CSS for Custom -->
<link rel="stylesheet" href="{% static 'css/custom.css' %} />

<script src="{% static 'js/vendor/modernizr.js' %}"></script>
</head>`

這部分是主體,上面的靜態文件正在正確加載,主體中也有一些要加載的圖像,它們位於同一文件夾中,但是我已將代碼編寫在另一個文件中並使用了{% include "images.html" %}以將其添加到基礎。

恩。 <img src="{% static 'top_scroll/images/demo/field.jpg' %}" alt="Demo image" id="field" /> <img src="{% static 'top_scroll/images/demo/gnome.jpg' %}" alt="Demo image" id="gnome" /> <img src="{% static 'top_scroll/images/demo/pencils.jpg' %}" alt="Demo image" id="pencils" /> <img src="{% static 'top_scroll/images/demo/golf.jpg' %}" alt="Demo image" id="golf" />

上面幾乎是圖像html文件上的所有代碼,任何人都知道為什么我不斷收到Invalid block標簽:“靜態”錯誤? 我的base.html頂部具有{%load staticfiles%},因此django是否在每個具有靜態功能的文件上都要求它,即使它被稱為文本包含?

是的,您應該在每個使用{% static %}標簽的模板中{% load staticfiles %}

文檔摘錄中的{% include %}標簽

include標記應被視為“呈現此子模板並包含HTML”的實現,而不應視為“解析此子模板並像其父對象一樣包含其內容”。 這意味着在包含的模板之間沒有共享狀態–每個包含都是一個完全獨立的渲染過程。

暫無
暫無

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

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