Render to file

1
2
3
4
from django.template.loader import render_to_string

def render_to_file(template, filename, context):
    open(filename, "w").write(render_to_string(template, context))

Comments

jezdez (on April 9, 2008):

indeed, very useful!

#

tekNico (on April 12, 2008):

Yeah, useful while living in fantASCII land: then you realize you need codecs.open instead. ;-)

#

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.