Skip to content Skip to sidebar Skip to footer

Images Not Rendering In HTML On Django Runserver, But HTML Works In Browser

Building a site with Django and my index.html page is not rendering images properly. The image loads up fine when I open the HTML file in the browser, but when I do python manage.p

Solution 1:

Django needs to know the location of the static content to server them. Do the following:

  1. Set the path for settings/STATIC_DIR to the place where you are storing your images
  2. Provide a STATIC_URL which would appear to client
  3. Pass the context_instance from your view code to the template
  4. Use the url in the template {{STATIC_URL}}path_to_your_image_from_static_dir

Solution 2:

Probably because of the file notation not being supported.

Try using the file:// URI scheme.


Solution 3:

Because your image source should be a URL not a file path.

You need to upload the image to the webserver and link to it's URL, like http://yourdomain.com/img/logo.jpg


Post a Comment for "Images Not Rendering In HTML On Django Runserver, But HTML Works In Browser"