python - 如何让 Django 模板引擎在内存模板中呈现?

标签 python django google-app-engine templates django-templates

我将我的模板存储在数据库中,我没有任何路径可以提供 template.render 方法。

是否有任何接受模板作为字符串的公开方法?

有什么解决办法吗?

最佳答案

基于 the docs使用模板系统:

from django.template import Template, Context

t = Template("My name is {{ my_name }}.")
c = Context({"my_name": "Adrian"})
t.render(c)

关于python - 如何让 Django 模板引擎在内存模板中呈现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2259743/

相关文章:

python - Django 合并 2 个具有相同值的字典/查询集

python - Scrapy 管道中的批量/批量 SQL 插入 [PostgreSQL]

django - 我如何限制 Django 中的 prefetch_related?

python - Django如何更新已保存在数据库中的多个字段的对象

google-app-engine - Google Code 与 Google App Engine?

java - RegisterActivity : cannot be resolved to a type, AppEngine

python - AppEngine - AppEngine HR 数据存储中奇怪的 ID 分配

python - 如何在 numpy 中添加计算/计算列?

django - Django 的最佳 Fabric 脚本

python - 如何在基于两列的数据框中堆叠聚合信息?