Forums

Media images not found in web app after production in Django.

Hi,

I am trying to serve image files in my Django web application. So i've successfully been able to upload my web app successfully but the only issue I am having is with uploading images and displaying them in the view. So, right now the image gets uploaded into the database but it does not render as it cannot be found.

My settings.py file looks like this: STATIC_URL = '/static/' STATIC_ROOT = '/home/hamzab96/Matcher/WebGroup/matcher/static'

MEDIA_URL = '/media/' MEDIA_ROOT = '/home/hamzab96/Matcher/WebGroup/matcher/media/images/'

The static files serve fine. But images do not show correctly.

In my Web Tab settings:

/static/ /home/hamzab96/Matcher/WebGroup/matcher/static

/media/ /home/hamzab96/Matcher/WebGroup/matcher/media/images

The images get uploaded to 'images/' via the models --> profile_pic = models.ImageField(upload_to='images/')

However, when I render in the template using user.profile_pic.url, the image is stating not found. This works fine in the development server.

What does the user.profile_pic.url resolve to?