Complete the code to set the URL path for serving media files in Django.
MEDIA_URL = '[1]'
The MEDIA_URL setting defines the base URL for media files uploaded by users. It usually ends with a slash, like /media/.
Complete the code to set the filesystem path where Django will store uploaded media files.
MEDIA_ROOT = os.path.join(BASE_DIR, '[1]')
The MEDIA_ROOT setting defines the absolute filesystem path where uploaded media files are saved. It is common to name this folder 'media'.
Fix the error in this Django settings snippet to correctly serve media files during development.
urlpatterns += static(settings.[1], document_root=settings.MEDIA_ROOT)When serving media files in development, you use static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) to map the URL to the filesystem path.
Fill both blanks to create a dictionary comprehension that maps filenames to their full media paths.
file_paths = {filename: os.path.join(settings.[1], filename) for filename in file_list if filename.endswith([2])}This comprehension builds a dictionary where each filename ending with '.jpg' is mapped to its full path inside MEDIA_ROOT.
Fill all three blanks to define a Django view that returns the URL of an uploaded media file.
def get_media_url(filename): return settings.[1] + [2] + filename + [3]
The function returns the full URL by joining MEDIA_URL and the filename without extra slashes because MEDIA_URL already ends with a slash.