About Lesson
Saving Files
Django saves uploaded files in the directory specified by the MEDIA_ROOT
setting, and the URL to access them is stored in the MEDIA_URL
setting.
- Configure
settings.py
: Add the following to handle media files:MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
- Accessing Files in Templates: Use
{{ MEDIA_URL }}
to access uploaded media in templates:
- Configure