I'm trying to pass a context (variables, parameters) to an xml template that has the following structure:
<infoTributaria>
<ambiente>1</ambiente>
<tipoEmision>1</tipoEmision>
<razonSocial>{{ razon_social }}</razonSocial>
<nombreComercial>{{ nombre_comercial }}</nombreComercial>
<ruc>{{ ruc }}</ruc>
<claveAcceso>{{ clave_acceso }}</claveAcceso>
....
.....
The code I try is the following:
context_xml ={
'razon_social':str(empresa.razon_social),
'nombre_comercial': str(empresa.nombre_comercial),
'ruc': str(empresa.ruc),
'establecimiendo': str(empresa.cod_estab),
'pto_emision': str(empresa.cod_pto_emision),
'direc_matriz': str(empresa.direc_matriz),
'direc_establecimiento': str(empresa.direc_estab),
'obligado_contabilidad': str(empresa.obligado_conta)
}
content = render_to_string('media/Facturacion/formato_sri.xml', context_xml)
with open(os.path.join(BASE_DIR, 'media/Facturacion/test.xml'), 'w') as xmlfile:
xmlfile.write(content.encode('utf8'))
The error it generates is:
TemplateDoesNotExist at / sales / manage_sales
media / Billing / sri.xml format
And the template exists in this path, the idea is to use the xml template and once the context is received, save it as a new document (test.xml)