![image](/static/img/ProfessionslsCommunity.png)
In this article I will try to solve most common problem in Django application we face, when it is running on production server with DEBUG = False
.
If we turn my debug to false images from the database wont show but if we return it to True everything works perfectly.
in project settings.py set MEDIA_URL
and MEDIA_ROOT
as bellow
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
in project urls.py
add following code -
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += [re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT, }), ]