I am trying to make an app where I can upload images through the Admin side, localhost:8000/admin/example
but when I upload an image it gives me a 404 error when I go to the image URL.
I am new to Django and python so I am trying to learn about both of them.
Here is what I have for models, URLs, and settings
models.py
item_image = models.ImageField(upload_to = "static/images/products" )
urls.py
from django.conf.urls.static import static
from django.conf import settings
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('<int:item_id>/', views.detail, name='detail'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
MEDIA_ROOT = PROJECT_ROOT + '/static/images/products/'
MEDIA_URL = '/media/'
html file
<img src={{item.item_image.url}}>