Skip to content

Django Media Files #37

Answered by daronzwink
daronzwink asked this question in Q&A
Discussion options

You must be logged in to vote

I may have been overthinking the configuration and I now have media files working. My configuration updates are below, and hopefully they look correct and can help others out.

src/config/settings.py

# Media files
# https://docs.djangoproject.com/en/4.2/topics/files/
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media_collected")

src/config/urls.py

from django.conf import settings
from django.conf.urls.static import static
...
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

.gitignore

# Media files
media_collected/

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by daronzwink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants