For whatever reason, after many hours of troubleshooting, I cannot seem to insert a local static file into a template or raw html with "img src". An image via a web url renders fine. Here are the relevant details:
Ownership of files is of the main user. Images are in the user's home folder and have r/w permission (same as all the executable scripts that work fine).
The server output reports: "GET /images/image.jpg HTTP/1.1" 200
Web browser shows the default browser placeholder image, as if it knows it should be there but doesn't have access to it.
view.py (tried many variations of the following):
from django.contrib import staticfiles
<img src="/abs/path/to/folder/image.jpg" class="img-responsive">
<img src="static/image.jpg" class="img-responsive">
<img src="image.jpg" class="img-responsive">
# (The above is an insert for the template)
index.html (the template):
{% load static %} # at the top
<img src="{{ STATIC_URL }}/image.jpg" class="img-responsive">
# The above would have been in the insert in view.py but for testing I tried the template also and it still doesn't work.
settings.py:
# Static files (CSS, JavaScript, Images)
STATIC_ROOT = os.path.join(os.path.dirname(__file__), 'static')
STATIC_URL = '/static/'
STATICFILES_DIR = ['/path/to/project/images/',
'/path/to/project/static/']
# Also tried absolute paths above and parenthesis instead of brackets for STATICFILES_DIR.
I have run manage.py collectstatic, although I think that only applies to apps. There is just a project folder, no apps.
Restarting the server after every change. Not sure where to go from here.