[Django]-Django Rest Framework Uploaded File Url

4👍

Define your MEDIA_URL and your MEDIA_ROOT into you settings.py

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

And add to your urls.py

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

MEDIA_ROOT is the absolute path where your file gonna be saved. And MEDIA_URL is the url that handles the media served from MEDIA_ROOT. And I should change upload_at=static to upload_to=bio/files, just because static path is for just static files as .css, .js and image files.

Leave a comment