django - 无法向我的模板添加不同的块标签
问题描述
我正在尝试在 for 循环中添加不同的块标签,但它会引发错误
您是否忘记注册或加载此标签?
但是我注册了
{% for todo in todo_list %}
{% if todo.complete %}{% else %}
{{todo.text|capfirst|truncatechars:150}} </a> <br>
<small class="text-muted">{{todo.content|capfirst}}{% empty %} {% endif %} </small> <hr>
{% endif %} {% endfor %}
谢谢
解决方案
调查你的问题,我认为你需要试试这个:
{% for todo in todo_list %}
{% if todo.complete %}
{% else %}
{{todo.text|capfirst|truncatechars:150}} </a> <br>
{% if todo.content %}
<small class="text-muted">{{todo.content|capfirst}} </small> <hr>
{% else %}
//do something
{% endif %}
{% endif %}
{% endfor %}
推荐阅读
- python - 将嵌套的 .h5 组读入 numpy 数组
- ios - 如何判断用户是否从主屏幕图标(没有 3D 触摸)打开了我的 iOS 应用程序?
- ruby-on-rails - Zip 流在生产环境中不起作用 (RAILS/AWS)
- javascript - Arrays.sort 比较器问题
- sql - 使用“using”而不是“on”交叉连接两个表
- javascript - 在同一段落中包含两个链接,在模态窗口中启动不同的图像
- html - 使用本地版本时丢失 BootStrap 格式
- html - 从 div 类中选择第一个 span 标签
- matlab - 在 Matlab 中使用 fscanf 从文本文件中读取一些缺失信息的数据
- c# - 具有嵌套依赖的类型的依赖注入