【发布时间】:2016-11-27 16:08:20
【问题描述】:
我无法使用以下语法在我的索引页面上加载图像
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block content %}
<-!---This is the statement-->
<-div data-src= "{% static "bootstrap/images/slider/slider-img1.jpg" %}">
<-/div>
{% endblock content %}
我在 div 中添加了一个额外的- (dash),因为帖子显示有困难。
无论如何我都会收到错误
Invalid block tag on line 69: 'static', expected 'endblock'. Did you forget to register or load this tag?
我认为这是一个目录结构。我的目录目前看起来像这样
|_mainApp
| |_______index.html ------>This is where i am trying to run the statement
|_templates
| |_______base.html ------->The statement works fine in the base
|_static
|_bootstrap
|_CenterApp
|_settings.py
|_urls.py
关于为什么我收到该错误的任何建议是位置问题并且找不到内容?还是别的什么?
【问题讨论】:
-
在尝试使用
static模板标签之前,您需要在模板顶部添加{% load 'static' %}。 -
是的,谢谢。你能把它作为答案吗
-
在我这边,关于“静态”的引用太多了。但它只适用于静态。谢谢。
标签: django tags block static-content