title: Generate custom xml with django
body: <p>As a heads up i am completely new to Python and Django.</p>
  
  <p>I am trying to move from PHP to Python. And i came to a problem of how to generate a custom xml file with all of the entries form database. I need to create something like this:</p>
  
  
  
  <p></p>
  
  <pre><code>&lt;inv&gt;
      &lt;invID&gt;1&lt;/invID&gt;
      &lt;group&gt;Group&lt;/group&gt;
      &lt;name&gt;Name&lt;/name&gt;
      &lt;description&gt;&lt;/description&gt;
  &lt;/inv&gt;
  &lt;inv&gt;
      &lt;invID&gt;2&lt;/invID&gt;
      &lt;group&gt;Group&lt;/group&gt;
      &lt;name&gt;Name&lt;/name&gt;
      &lt;description&gt;&lt;/description&gt;
  &lt;/inv&gt;
  </code></pre>
  
  <p></p>
  
  <p>UPDATE</p>
  
  <p>For those wondering here is the final code for the saving of the XML There is obviously got to be a better way but this is what i came up with.</p>
  
  <pre><code>def xml(request):
  #Getting all of the items in the Database
  products = Product.objects.all()
  #Putting all of it in to Context to pass to template
  context = {
      'products': products
  }
  #calling template with all  of the information
  content = render_to_string('catalog/xml_template.xml', context)
  #Saving template tp a static folder so it can be accessible without calling view
  with open (os.path.join(BASE_DIR, 'static/test.xml'), 'w') as xmlfile:
      xmlfile.write(content.encode('utf8'))
  #Not Sure if i actually need to call the return but i did not let me run it without content
  return render(request, 'catalog/xml_template.xml', context)
  </code></pre>