I'm creating a website where i can upload catalogues on a downloads page and users can download them, i can achieve this for a single file by using the following code in the view, but i need a simpler way i can do this on the admin or on a template.
def brochure(request):
fs = FileSystemStorage()
filename = 'kastom_profile.pdf'
if fs.exists(filename):
with fs.open(filename) as pdf:
response = HttpResponse(pdf, content_type='application/pdf')
response['Content-Disposition'] = 'inline;filename="kastom_profile.pdf"'
return response
else:
return HttpResponseNotFound('The requested pdf was not found in our server.')