【问题标题】:Django Is it possible to write text outside block in child templateDjango是否可以在子模板中的块外写入文本
【发布时间】:2015-02-19 18:05:34
【问题描述】:

我正在尝试执行以下操作

{% block csslinks %} 
    <link rel="stylesheet" type="text/css" href="{% static 'hello/style.css' %}">
{% endblock %}

我知道这是不可能的,但有什么替代方案? Django : Is it impossible to static tag into block tag? 有一个类似的问题

有人建议我去{% load staticfiles %}没有回答在这里写什么?

{% block csslinks %} 
    <link rel="stylesheet" type="text/css" href="what to write here to include css?">
{% endblock %}

【问题讨论】:

  • 什么是不可能的,这与块外的文本有什么关系?

标签: python django django-templates django-staticfiles


【解决方案1】:

我没有任何问题

{% block csslinks %} 
   <link rel="stylesheet" type="text/css" href="{% static 'hello/style.css' %}">
{% endblock %}

只要{% load staticfiles %} 在同一个模板的顶部..

【讨论】:

    猜你喜欢
    • 2015-08-26
    • 1970-01-01
    • 2023-03-21
    • 2017-12-30
    • 2012-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多