I have a template where I render a response from a web service.
def XMLResponseView9request):
...
with open(archivo_request,"r") as archivo:
request_data = archivo.read()
headers = {'Content-type':'text/xml'}
data_response = requests.post(target_url, data=request_data, headers=headers)
jdato = xmltodict.parse(data_response.content)
data_xml = data_response.text
data_template = json.dumps(jdato)
return render_to_response('response.html',
{'data':data_template,'dataxml':data_xml},
context_instance=RequestContext(request))
Beside of render the response I want to serve the response as a file (xml or txt) to be downloaded.
I try passing the response as text (variable: data_xml) and served through a simple javascript function, but the file is empty or only have one line "[object Object]".
Is possible serve the response as file from the DJANGO view instead of passing the text to the template.
Thanks in advance