i write make an xml file and save it to the database with filefield and i want to make a download link to template. it is my view:
def xmlFile(request):
all = request.POST
data = dict(all)
username = User.objects.get(username=request.user)
xml = xmlFirst.dataToXml(data)
with open('web/data/Fuzzy'+ str(username.username)+'1.xml','w') as myfile:
myfile.write(xml)
xmlFile = XmlFile(username= username, upload='Fuzzy'+ str(username.username)+'1.xml')
xmlFile.save()
xmlLink = XmlFile.objects.first()
a = xmlLink.upload
context = {'data':a}
return render(request, 'xmlFile.html', context)
how can i reach the download link? and my template is :
<!DOCTYPE html>
<html>
<head>
<title>aa</title>
</head>
<body>
<a href="{{data}}">{{data}}</a>
</body>
</html>
when i click on that link it has http://localhost:8003/xmlFile/FuzzyMirab1.xml that i want to be my file path that is in
web
data
FuzzyMirab1.xml
i need my link will be http://localhost:8003/data/FuzzyMirab1.xml