[Answered ]-Django templates โ€“ not displaying dynamic images

2๐Ÿ‘

โœ…

Try doing something like this is your settings.py:

MEDIA_SERVER_URL = 'http://www.example.com/'
MEDIA_URL = os.path.join(MEDIA_SERVER_URL, 'images/')

and then do

src="{{ MEDIA_URL }}{{ example.image.url }}"

Also check for permissions:

  1. Media Directory (/home/nicpon/Dokumenty/aplikacje/images/): Should allow read by your webserver (eg: chgrp www-data images)
  2. Your webserver should be configured to handle media serving appropriately. Ideally a separate media server can be used, but you should check the respective URLs if you are having django serve the media (as seems to be the case from your urls.py)
๐Ÿ‘คPriyeshj

Leave a comment