Why does this function download an entire web page?
views.py
def download_file(request,path):
file_path=os.path.join(settings.MEDIA_ROOT,path)
if os.path.exists(file_path):
with open(file_path, 'rb') as enm:
response=HttpResponse(enm.read(),content_type="application/adminupload")
response['Content-Disposition']='Inline;filename='+os.path.basename(file_path)
return response
template index.html
<div>
{% for post in file %}
<h2>{{post.title}}</h2>
<a href="{{post.admin.upload.url}}" class="home__button anime-text" download="{{post.admin.upload.url}}">DOWNLOAD CV</a>
{% endfor %}
</div>
urls.py
re_path(r'^download/(?P<path>.*)$',serve,{'document_root':settings.MEDIA_ROOT}),
I am trying to download a pdf file when i hit download, the function downloads the webpage and saves it with an extension of (.htm)