django - django内部的两个模板无法解析剩余部分
问题描述
我Could not parse the remainder: '"' from '"'
在这部分代码中遇到了错误:
{% include 'test.html' with pic_url="{% static 'picture.jpg' %}" %}
是否可以在 Django 模板中编写类似的内容?
解决方案
您不能像这样组合模板标签。
您可以做的是将一个模板标签的结果分配给变量。并非所有模板标签都可以,但static
标签可以:
{% static 'blog-single.html' as some_variable %}
{% include 'test.html' with post_url=some_variable %}
推荐阅读
- python - Boto3 - 可能将生成器对象上传到 s3?
- python - 有没有办法修复 lamda aws 上的 numpy 错误?
- powershell - 识别代理地址中的无效域(比较数组)
- python - 如何将初始化数组作为 OUT 参数传递给 COM 调用
- c++ - 静态类成员的初始化引发“未命名类型”错误
- node.js - 安装 postgresql 12 时出现运行时错误?
- html - html 按钮在单击时未加载 document.location
- c++ - 为什么将`const`修饰符应用于保存结构值的变量会使结构值不可变?
- angular - 忽略根 RouterModule 中的路径
- amazon-web-services - AWS Step 函数可以异步运行 bash 脚本吗?