Not allowed to load local resource in Django (Images)

I'm trying to load multiple images using Django rest API but getting the error as - Not allowed to load local resource.

the setting of app is -

STATIC_URL = '/static/'

    os.path.join(BASE_DIR, 'static')

STATIC_ROOT = os.path.join(BASE_DIR, 'assets')

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

I have checked multiple solution on google but is this due to chrome or Django? Can anyone help here please.

NOTE: The call of the API is giving 200 response but only rendering is not happening. Thanks!!

You need to connect the STATIC_... and MEDIA_... to <projectname>/

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [...]

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

Back to Top