【发布时间】:2011-01-16 14:44:57
【问题描述】:
我将我的模板存储在数据库中,我没有任何路径可以提供template.render 方法。
是否有任何接受模板作为字符串的公开方法?
有什么解决办法吗?
【问题讨论】:
标签: python django google-app-engine templates django-templates
我将我的模板存储在数据库中,我没有任何路径可以提供template.render 方法。
是否有任何接受模板作为字符串的公开方法?
有什么解决办法吗?
【问题讨论】:
标签: python django google-app-engine templates django-templates
基于the docs使用模板系统:
from django.template import Template, Context
t = Template("My name is {{ my_name }}.")
c = Context({"my_name": "Adrian"})
t.render(c)
【讨论】:
Instantiate Template 带有用作模板的字符串。
【讨论】:
在 Django
from django.template.loader import get_template_from_string
tpl = Template(get_template_from_string("My name is {{ my_name }}."))
【讨论】:
get_template_from_string(template_code) 在 Django 1.8 中被删除,因为……”