[Fixed]-Django get media url in view function

25👍

You can access to your settings variables by:

from django.conf import settings

your_media_root = settings.MEDIA_ROOT

But you can also access to the file path as the same way you get the name:

name = file_path.file.name
url = file_path.file.url
path = file_path.file.path
👤cor

Leave a comment