Broken image in Django

292 Views Asked by At

im getting a broken image i tried almost everything looked at a lot of questions but still not working

settings.py


STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "static_root")

STATICFILES_DIRS = [
    os.path.join(os.path.dirname(BASE_DIR), "static", "static_files")

]

urls.py


urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.home, name='home'),
    path('products/', views.all, name='products')
]

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

the html file

{% for item in product.productimage_set.all%}
{% if item.featured %}
        <div><img src="{{ MEDIA_URL }}{{ item.image }}"/></div>
{% endif %}

0

There are 0 best solutions below