Forums

Media files does not work

This is my settings.py:

MEDIA_ROOT = u'/home/user/aii/media'
MEDIA_URL = '/media/'
STATIC_ROOT = u'/home/user/aii/static'
STATIC_URL = '/static/'

My Static files in Pythonanywhere config:

/media/      /home/user/aii/media

HTML template:

img src="{{ habitacion.imagen1 }}" class="img-responsive" alt="{{ habitacion.nombre }}"

When I see the HTML, {{ habitacion.imagen1 }} it's giving to me this URL: www.user.pythoanywhere.com/home/user/aii/media/20170129190843/a39.jpg

And I need this: www.user.pythoanywhere.com/media/20170129190843/a39.jpg

Hi there,

Everything in your settings.py and your description of the web tab static files config looks OK to me. I'm not sure how that magical habitacion.imagen1 works, but that might be the culprit?

One thing, you don't want "www.user.pythonanywhere.com". Just "user.pythonanywhere.com".

Thanks for your time. Problem solved with a reset.

:)