Image filepath showing in template instead of the actual image

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

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

In my settings.py I have the following:

#settings.py
STORAGES = {

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

}

MEDIA_DIR = BASE_DIR / 'media'
#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

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

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

{{ article.image.url }}

You would think, wouldn’t you?

Screenshot 2024-04-05 130306

Screenshot 2024-04-05 130233

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.

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!?

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

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.)