# Image filepath showing in template instead of the actual image

**URL:** <https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862>\
**Category:** Mystery Errors\
**Created:** [April 5, 2024, 11:44am UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862 "2024-04-05T11:44:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlauweStadTechnologi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/blauwestadtechnologi/32/15959_2.png) [@BlauweStadTechnologi](https://forum.djangoproject.com/u/BlauweStadTechnologi)\
**Post date:** [April 5, 2024, 11:44am UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862/1 "2024-04-05T11:44:34Z")

</div>

Right, here is my setup, in my `media/models` directory:

```auto
#models.py
image = models.ImageField(upload_to='assets/')

```

In my `settings.py` I have the following:

```auto
#settings.py
STORAGES = {

    'default': {
        'BACKEND': 'django.core.files.storage.FileSystemStorage',
    },

}

MEDIA_DIR = BASE_DIR / 'media'

```

```auto
#template.html
{{article.image}}

```

Is there any particular valid reason as to why I get the text string on the directory of the file rather than the actual image?

Thank you

---

<div class="post-metadata">

**Author:** ![rob8624](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rob8624/32/10022_2.png) [@rob8624](https://forum.djangoproject.com/u/rob8624)\
**Post date:** [April 5, 2024, 11:49am UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862/2 "2024-04-05T11:49:43Z")

</div>

Use Image.url, you are just seeing a str representation of the image object.

---

<div class="post-metadata">

**Author:** ![BlauweStadTechnologi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/blauwestadtechnologi/32/15959_2.png) [@BlauweStadTechnologi](https://forum.djangoproject.com/u/BlauweStadTechnologi)\
**Post date:** [April 5, 2024, 11:52am UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862/3 "2024-04-05T11:52:32Z")

</div>

…aaaand how would I do that in the context of deriving that image from the model?

---

<div class="post-metadata">

**Author:** ![rob8624](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rob8624/32/10022_2.png) [@rob8624](https://forum.djangoproject.com/u/rob8624)\
**Post date:** [April 5, 2024, 12:00pm UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862/4 "2024-04-05T12:00:43Z")

</div>

{{ article.image.url }}

---

<div class="post-metadata">

**Author:** ![BlauweStadTechnologi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/blauwestadtechnologi/32/15959_2.png) [@BlauweStadTechnologi](https://forum.djangoproject.com/u/BlauweStadTechnologi)\
**Post date:** [April 5, 2024, 12:03pm UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862/5 "2024-04-05T12:03:58Z")

</div>

You would think, wouldn’t you?

![Screenshot 2024-04-05 130306](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/f/d/fdb41014dfe0fcc24efcfa01dc9d6932d9152fd0.png)

![Screenshot 2024-04-05 130233](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/7/5/75462321e2da82ead3ea699b6dcd4a495f9cbd5d.png)

Why am I getting logs telling me that it is not finding the image despite correctly configuring the directory and the image being in said directoy? It’s silly, petty things like this that take so much effort - things that I have done correctly and so should just be simple.

```auto
Not Found: /assets/<IMAGENAME>.jpg
WARNING:django.request:Not Found: /assets/<IMAGENAME>.jpg

```

Does Django need a new prescription from the optitians?

The image is in the correct directory, WHY CAN IT NOT FIND THE BLOODY IMAGE!?

---

<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:** [April 5, 2024, 12:18pm UTC](https://forum.djangoproject.com/t/image-filepath-showing-in-template-instead-of-the-actual-image/29862/7 "2024-04-05T12:18:20Z")

</div>

I’m assuming this is still a development environment where you’re using runserver?

If so, you need to follow the steps documented at [How to manage static files (e.g. images, JavaScript, CSS) | Django documentation | Django](https://docs.djangoproject.com/en/5.0/howto/static-files/#serving-files-uploaded-by-a-user-during-development)

A url is _not_ a reference to a file. A url is a reference to a “location” - the semantics of that location being solely defined by the web server. On a real web server, that location generally has _nothing_ to do with the directory / file path of an actual file. (This is a fundamental principle of the HTTP protocol, this isn’t unique to Django.)
