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))

More like this

  1. head inclusion middleware by bowdengm 3 years, 3 months ago
  2. Caching XHTML render_to_response by smoonen 3 years, 10 months ago
  3. Create PDF files using rml and django templates by mporrato 4 years, 10 months ago
  4. email rendered via javascript (trick spam crawlers) by rizumu 2 years, 9 months ago
  5. Decorate Template Tag (In-Line include and extend with local context) by rhomber 2 years, 4 months ago

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?)