Jam*_*nco -1 tags django block static-content
我无法使用以下语法在我的索引页上加载图像
{% 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 %}
Run Code Online (Sandbox Code Playgroud)
我- (dash)
在 div 中添加了一个额外的内容,因为该帖子难以显示。
无论如何,我收到错误
Invalid block tag on line 69: 'static', expected 'endblock'. Did you forget to register or load this tag?
Run Code Online (Sandbox Code Playgroud)
我认为这是一个目录结构。我的目录目前看起来像这样
|_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
Run Code Online (Sandbox Code Playgroud)
关于为什么我收到该错误的任何建议是位置问题并且无法找到内容?或者是别的什么 ?
用
{% load staticfiles %}
Run Code Online (Sandbox Code Playgroud)
下面你已经扩展了你的 base.html
在 Django 模板中,每当您在模板中使用静态时调用 {% load staticfiles %} 很重要。更多细节在这里
归档时间: |
|
查看次数: |
1294 次 |
最近记录: |