python - Flask 渲染模板
问题描述
我尝试将数据插入到我的模板 render_template。
data = Bill.bill_data(self)
return render_template('templates/bill.html', **data)
文件夹模板中的账单模板位置。但我有这个错误
jinja2.exceptions.TemplateNotFound: templates/bill.html
我的数据如下所示:
data={
"payer_currency": "5",
"shop_amount": "5",
"shop_currency": "5",
"shop_id": "5",
"shop_order_id": "12",
"sign": ""
}
解决方案
您不必添加templates/
路径。作为文件夹中的默认render_template
搜索模板templates
return render_template('bill.html', **data)
推荐阅读
- matlab - 如何根据“x”值绘制具有不同方程的图形
- cypress - Cypress-File-Upload 插件的替代品
- javascript - 如何使用javascript将字符串数组转换为布尔值?
- python - 如何分别从 docx 和纯文本中获取表格数据?
- c++ - 致命错误:在 Mac OS Monterey 上找不到“unistd.h”文件
- java - 从数据库下载文件:找不到类 java.io.ByteArrayInputStream 的序列化程序,也没有发现创建 BeanSerializer 的属性
- python - 使用 df.at[] += x 增加 DataFrame 的单元格值不起作用
- mysql - 如何在mysql之上的spark中查询字符串时间
- c - 从另一个文件中未定义的对“功能”的引用
- java - 如何使用 Lombok 生成只接受部分参数的构造函数?