# How to access user uploaded files

**URL:** <https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604>\
**Category:** Forms & APIs\
**Created:** [March 14, 2022, 6:41pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604 "2022-03-14T18:41:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TommyQuality](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tommyquality/32/6302_2.png) [@TommyQuality](https://forum.djangoproject.com/u/TommyQuality)\
**Post date:** [March 14, 2022, 6:41pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/1 "2022-03-14T18:41:56Z")

</div>

Hi,

I have an image upload field within my model and what to show the image within other screens. Whats the correct way to display these images within a production environment?

I’ve set a media root path within the `settings.py` and the path in the model which is working.

Ideally, i’d like to access the file in the same way as using `{% static '' %}assets/img/uploadedfile.jpg" `but i think this only works when using collectstatic?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 14, 2022, 7:00pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/2 "2022-03-14T19:00:39Z")

</div>

Do **not** confuse “static” files with “media” files.

Static files are created and managed as part of the project itself.

Media files are user-uploaded files.

They have separate settings and configuration options. They are managed and controlled differently.

See all the docs on Media Files.

---

<div class="post-metadata">

**Author:** ![TommyQuality](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tommyquality/32/6302_2.png) [@TommyQuality](https://forum.djangoproject.com/u/TommyQuality)\
**Post date:** [March 14, 2022, 7:33pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/3 "2022-03-14T19:33:50Z")

</div>

I’ve looked over these, but I find the documentation hard to follow. I’ve set the media root and url. and then I’m lost at what to do next in order for me to pass the image path into my template.

I am making progress with Django/Python but I think the documentation for beginners isn’t the easiest to follow. Hence why I ask a lot of questions on here.

I’ll keep trying different things to see if I can get any further.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 14, 2022, 8:36pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/4 "2022-03-14T20:36:39Z")

</div>

One of the key differences between static files and media files is that media files are represented by a FileField in a model. Take a look at the [FileField docs](https://docs.djangoproject.com/en/4.0/ref/models/fields/#filefield) to find what attribute of that field is available to you to get the url for a file.

---

<div class="post-metadata">

**Author:** ![TommyQuality](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tommyquality/32/6302_2.png) [@TommyQuality](https://forum.djangoproject.com/u/TommyQuality)\
**Post date:** [March 14, 2022, 8:48pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/5 "2022-03-14T20:48:22Z")

</div>

Thanks, Ken. So do I need to create a path in the `url.py` to get to the `{{ object.mug_shot.url }}`. I can’t see this in the documentation.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 14, 2022, 8:54pm UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/6 "2022-03-14T20:54:28Z")

</div>

See [Serving files uploaded by a user during development](https://docs.djangoproject.com/en/4.0/howto/static-files/#serving-files-uploaded-by-a-user-during-development.)

---

<div class="post-metadata">

**Author:** ![TommyQuality](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tommyquality/32/6302_2.png) [@TommyQuality](https://forum.djangoproject.com/u/TommyQuality)\
**Post date:** [March 15, 2022, 11:59am UTC](https://forum.djangoproject.com/t/how-to-access-user-uploaded-files/12604/7 "2022-03-15T11:59:27Z")

</div>

Thanks again, Ken. I must have been missing the links to the other documentation you provided.

This is working now but will look at serving the files from some kind of storage account so that I can run this in production.

Cheers

Tom
