Skip to content

Instantly share code, notes, and snippets.

@Nipun2016
Last active February 9, 2018 06:03
Show Gist options
  • Save Nipun2016/d82a0a4f82d2f2e9177c05ab8186d37c to your computer and use it in GitHub Desktop.
Save Nipun2016/d82a0a4f82d2f2e9177c05ab8186d37c to your computer and use it in GitHub Desktop.
You will need to set MEDIA_URL and MEDIA_ROOT in your project’s settings.py.
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
In the development server you may serve the user uploaded files (media) using django.contrib.staticfiles.views.serve() view.
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# Project url patterns...
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment