R
R
rjunovskii2022-03-08 16:58:31
Django
rjunovskii, 2022-03-08 16:58:31

Media display not working in Django?

For some reason, the display of media files is blocked.

In the settings.py file, I wrote everything that is needed:

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


I also registered the necessary urls in the root url.py:
urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include('djoser.urls')),
    path('api/v1/', include('djoser.urls.authtoken')),
    path('api/v1/', include('product.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


The image is saved to the root directory, a link is created to it in the json file of the rest of the framework:
6227605eec1ad921994299.png

But when I click on the image link, this comes up:
62276092790b2861526143.png

I already have no idea what's wrong, I searched all over, I didn't find anything. help me please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Markin, 2022-03-08
@rjunovskii

Update your browser, disable extensions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question