blog images not shown when DEBUG = False

Hi, I am using aws elasticbeanstalk(Python 3.7 running on 64bit Amazon Linux 2/3.5.2) for my Django project. So I deployed project to elasticbeanstalk by following https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html and with no issue I can see my static and images applied correctly. But when I add a blog image is not shown if DEBUG = False in my settings.py when I deployed. But if it is DEBUG = True, I see blog and images with no issue. I added screenshot below

settings.py

STATIC_URL = ‘/static/’
if DEBUG:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, ‘static’)
]
else:
STATIC_ROOT = os.path.join(BASE_DIR, ‘static’)

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

urls.py

urlpatterns = [
path(‘’, views.HomeView.as_view(), name=‘home’),
path(‘blog/’, views.blog, name=‘blog’),
path(‘blog/int:blog_id/’, views.blog_details, name=‘blog_details’),
path(“ckeditor/”, include(‘ckeditor_uploader.urls’)),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Before setting the DEBUG off run command

python manage.py collectstatic

You will be good to go for deployement :+1:.

Welcome @caped-baldys !

This is part of a solution, but not the complete answer. In addition to this, you need to ensure that STATIC_ROOT is set correctly and matches how the web server is configured. You also need to ensure that the web server has STATIC_ROOT mapped to the same URL path as STATIC_URL and that the web server has access to that directory.