C
C
Chekistchek2017-09-01 15:38:35
Django
Chekistchek, 2017-09-01 15:38:35

Why are the pictures that I upload through the admin panel not displayed on the "combat" server?

If debug:true is set on the server, then everything works, and if false, then the request cannot find the path to the directory and does not display the image.
settings.py:

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

app/urls.py:
if settings.DEBUG:
    if settings.MEDIA_ROOT:
        urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += staticfiles_urlpatterns()

I understand that I need to add a url with the correct path, but I can't figure out which one and how. The folder for the photo is located in the root of the project

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question