title: Django: Streaming dynamically generated XML output through an HttpResponse
body: <p>recently I wanted to return through a Django view a dynamically generated XML tree. The module I use for XML manipulation is the usual cElementTree.</p>
  
  <p>I think I tackled what I wanted by doing the following:</p>
  
  <pre><code>def view1(request):
      resp = HttpResponse(g())
      return resp
  
  def g():
       root = Element("ist")
       list_stamp = SubElement(root, "list_timestamp")
       list_creation = str(datetime.now())
  
       for i in range(1,1000000):
           root.text = str(i)
           yield cET.tostring(root)
  </code></pre>
  
  <p>Is something like this a good idea ? Do I miss something ?</p>