DEV Community

Cover image for Django Staticfiles and Media not showing when DEBUG = False [Fixed]
Odipo Otieno (KwargDevs)
Odipo Otieno (KwargDevs)

Posted on Edited on

Django Staticfiles and Media not showing when DEBUG = False [Fixed]

In urls.py in project *not * app urls.py:
imports:

from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns # new



from django.conf import settings

from django.views.static import serve

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026 ⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026

urlspatterns :

urlpatterns = [
re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
]
⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026 ⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026

Settings.py


STATIC_URL = '/static/'

MEDIA_URL = '/media/'

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')

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026 ⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026

It Works, Subscribe to my YouTube Channel KwargDevs

Top comments (8)

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
fatihkurtl profile image
Fatih Kurt •

Thanks man, it helped me a lot

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
ramesh_shrestha_4c2ff6339 profile image
Ramesh Shrestha •

I appreciate man.

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
asadbek_abdubannopov_3c5f profile image
Asadbek Abdubannopov •

Thank you bro🔥

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
beta02 profile image
Sam •

it help me a lot

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
ashimghoshfm profile image
Ashim Ghosh •

Thanks Boss

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
salin_bade_b2beeacc07e1d7 profile image
Salin Bade •

thank you

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
ryeounhoward profile image
Ryeoun Howard •

is there an update about this since python has new version?

⭐ Football Update: vincod/django staticfiles and media not showing when debug false fixed a - Info Live Streaming 2026
 
vincod profile image
Odipo Otieno (KwargDevs) • • Edited

I'll try it on the new version then update you