Html 无法在Django for AMP页面中加载字体
在AMP页面上,我想在styles标签中添加对我字体的引用。 我们可以使用static这样做吗Html 无法在Django for AMP页面中加载字体,html,css,django,Html,Css,Django,在AMP页面上,我想在styles标签中添加对我字体的引用。 我们可以使用static这样做吗 @font-face { font-family: 'Font Awesome 5 Brands'; font-style: normal; font-weight: normal; src: url("{% static '/webfonts/fa-brands-400.eot' %}"); src: url("{% static '/webfonts/fa-brands-400
@font-face {
font-family: 'Font Awesome 5 Brands';
font-style: normal;
font-weight: normal;
src: url("{% static '/webfonts/fa-brands-400.eot' %}");
src: url("{% static '/webfonts/fa-brands-400.eot?#iefix' %}") format("embedded-opentype"), url("{% static '/webfonts/fa-brands-400.woff2' %}") format("woff2"), url("{% static '/webfonts/fa-brands-400.woff' %}") format("woff"), url("{% static '/webfonts/fa-brands-400.ttf' %}") format("truetype"), url("{% static '/webfonts/fa-brands-400.svg#fontawesome' %}") format("svg"); }
在我的身体部位,这对我来说很好
<amp-img
src="{% static '\located_in\picture.jpg' %}"
width="16"
height="9"
layout="responsive"
>
</amp-img>
在访问Django静态目录中的任何文件之前,需要使用jinja2加载静态文件 例如:
{%load staticfiles%}
我不得不在我的文件中再次添加{%load staticfiles%}
,即使它是在base中。html是的,即使它是,{%load static%}
是特定于您正在处理的模板的标记。Jinja是Djangoit的默认TL。它的语法非常接近Jinja2,并且设计为。它说:“Django的模板语言旨在在强大和轻松之间取得平衡。它旨在让那些习惯于使用HTML的人感到舒适。如果你接触过其他基于文本的模板语言,如Smarty或Jinja2,你应该对Django的模板感到自在。”。它是使用django admin startproject时启用的默认语言,仅当您手动执行此操作时才会更改。
Error during template rendering
In template
C:\users\frank\desktop\test_env\src\templates\fontawesome\fontawesome-all.css, error at line 2702
Invalid block tag on line 2702: 'static'. Did you forget to register or load this tag?
{% load staticfiles %}
<amp-img src="{% static '\located_in\picture.jpg' %}" width="16" height="9" layout="responsive" > </amp-img>