Enable media display in django in development server
1. Enable the media context processor, from settings.py file
django.template.context_processors.media
2. Set MEDIA_URL and MEDIA_ROOT in settings.py file
MEDIA_URL = '/media'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
3. Serve the media from development server in url.py file
# Serving media files during development
# Can be written this line directly in the development.py settings file
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
4. Load the images in template
<img src="{{MEDIA_URL}}{{user.profile_image">