# Django problem with downloading file from my computer

**URL:** <https://forum.djangoproject.com/t/django-problem-with-downloading-file-from-my-computer/32066>\
**Category:** Mystery Errors\
**Created:** [June 13, 2024, 2:37pm UTC](https://forum.djangoproject.com/t/django-problem-with-downloading-file-from-my-computer/32066 "2024-06-13T14:37:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rwyszynski](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rwyszynski/32/21953_2.png) [@Rwyszynski](https://forum.djangoproject.com/u/Rwyszynski)\
**Post date:** [June 13, 2024, 2:37pm UTC](https://forum.djangoproject.com/t/django-problem-with-downloading-file-from-my-computer/32066/1 "2024-06-13T14:37:09Z")

</div>

I am new in Django and I need some assist. I want to download the file which path is in plik.localisation (it has been taken from loop). The problem is with the path. Could someone help me what I am doing wrong? My view.py is:

```auto
def download(request, path):
    file_path = os.path.join(settings.MEDIA_ROOT, path)
    if os.path.exists(file_path):
        with open(file_path, 'rb') as fh:
            response = HttpResponse(fh.read(), content_type="application/pdf")
            response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
            return response
    raise Http404

```

Urls

```auto
 path('download/<str:path>',views.download, serve, name="download"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

```

Html where {{plik.localisation}} is a comes from for loop (plik.localisation in lacalisation)

```auto
<div class="com">
       {{plik.localisation}} <a href="{% url 'download/path' %}" class="button">download</a>
</div>

```
