Skip to content

Instantly share code, notes, and snippets.

@BrunoMoreno
Created July 29, 2025 17:45
Show Gist options
  • Select an option

  • Save BrunoMoreno/5d4de435a76f700d7d4edfae7ef01ea9 to your computer and use it in GitHub Desktop.

Select an option

Save BrunoMoreno/5d4de435a76f700d7d4edfae7ef01ea9 to your computer and use it in GitHub Desktop.
django static files config
# settings.py
STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / "static",
]
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
# urls.py
from django.conf import settings
from django.conf.urls.static import static
# in the end of file
# if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment