django - django 模板,使用 {% with %} 设置列表变量
问题描述
我需要在 django 模板中硬设置一个列表。我知道我必须传递变量to the template
,而不是创建它们in the template
,但我只能访问模板文件。我将 sendinblue 与自定义模板一起使用,使用注入模板的自定义参数的唯一方法是使用他们的 api。我只需要硬编码列表中的一些内容,内容会根据联系人动态显示,我认为仅为此使用api是大材小用。
解决方案
{% with tt='123'|make_list %}
{{ tt }}
<hr>
{% for x in tt %}
{{ x }}<br>
{% endfor %}
{% endwith %}
尝试这个
推荐阅读
- vue.js - 如何将数据从我的 API 构建到 Apx 图表
- r - 如何让 getURL 在 Windows 10 上的 R 上工作?[tlsv1 警报协议版本]
- animation - 使用向量算术的 SwiftUI 线图动画
- reactjs - 为什么 React 不重定向到路由?
- html - Bootstrap 网格列表视图等宽
- nestjs - Visual Studio Code:在非调试模式下开始在断点处停止并抱怨
- ruby - 查询返回不正确结果的 Mongoid ruby
- angular - 获取 Angular 中所有任务的列表
- java - 第三面板没有出现
- php - Symfony 5 不会加载 CSS 文件