How to make Django template engine to render in memory templates?

后端 未结 3 1977
忘掉有多难
忘掉有多难 2021-02-05 04:59

I am storing my templates in the database and I don\'t have any path to provide for the template.render method.

Is there any exposed method which accepts th

3条回答
  •  佛祖请我去吃肉
    2021-02-05 05:27

    Based on the the docs for using the template system:

    from django.template import Template, Context
    
    t = Template("My name is {{ my_name }}.")
    c = Context({"my_name": "Adrian"})
    t.render(c)
    

提交回复
热议问题