I just simply want to show my static image in template. I have looked every possible ways to solve this issue and try various approaches but could not get my static images in template. The alternative text of the respective image is shown but image itself not loaded and get this in terminal Window
"GET /static/image/down.jpg HTTP/1.1" 404 1771
here how my Django project is laid out is given below project files hierarchy
in urls.py
from django.conf.urls import include,url
from django.contrib import admin
from django.urls import path
from myapp import views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
.......]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root= settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
in settings.py
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
MEDIA_URL= "/media/"
in template question.html
i have tried different approaches to access the image[with {% load static %} tag on the top of html page] like
<img src="{% static 'image/down.jpg' %}">
<img style="width: 245px; height: 247px;"
alt="Image description"
src="{% static 'image/down.jpg' %}"/>
<img src="/static/image/up.jpg" alt="Second-image" />
but could not get the problem solved
Make sure you have pillow installed correctly and if it still wont work, try reinstalling pillow.