Load django template from the database

Posted by Björn Lindqvist on Stack Overflow See other posts from Stack Overflow or by Björn Lindqvist
Published on 2010-03-17T14:02:19Z Indexed on 2010/03/17 20:01 UTC
Read the original article Hit count: 514

Hello,

Im trying to render a django template from a database outside of djangos normal request-response structure. But it appears to be non-trivial due to the way django templates are compiled. I want to do something like this:

>>> s = Template.objects.get(pk = 123).content
>>> some_method_to_render(s, {'a' : 123, 'b' : 456})
>>> ... the rendered output here ...

How do you do this?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-templates