Static And Media Files In Django

[Solved] Static And Media Files In Django | Basic - Code Explorer | yomemimo.com
Question : django static media

Answered by : condemned-chamois-xmmve66rgq4b

from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [ # ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# ----------------or----------------
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Source : https://docs.djangoproject.com/en/4.0/howto/static-files/ | Last Update : Mon, 03 Jan 22

Question : static and media files in django

Answered by : vipin-yadav

# in settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [ BASE_DIR / "static" ]
STATIC_ROOT = "static_root"
MEDIA_URL = '/media/'
MEDIA_ROOT = "media_root"
# in ulrs.py
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [ ... ]
if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)	urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# in .gitignore add media_root, static_root

Source : | Last Update : Fri, 23 Sep 22

Question : staticfiles

Answered by : kevin-tempel

STATICFILES_DIRS = [BASE_DIR / 'static']

Source : | Last Update : Wed, 14 Oct 20

Answers related to static and media files in django

Code Explorer Popular Question For Basic