[Fixed]-Django- how to serve an image in all templates of django app?

1👍

The MEDIA_URL setting should be an absolute URL, e.g.

MEDIA_URL = '/files/'

At the moment, you have a relative URL 'files/'. That means that the URL changes depending on which page you are on. When you visit www.mysite.com/index, the relative URL expands to www.mysite.com/files/avatars/avatar.jpg which works, but when you visit www.mysite.com/v1/v2/v3, the relative URL is expanded to www.mysite.com/v1/v2/files/avatars/avatar.jpg which is incorrect.

Leave a comment