I was trying to save an image but it can't be displayed through the browser. It was successfully saved in the exact location but when I pasted the link it says, "Page not found". Could someone help me with what's going on?
See output: Browser View
Code: Code Snippet
Settings configuration:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_LOCATION = "static"
MEDIA_LOCATION = "media"
CodePudding user response:
settings.py
from pathlib import Path
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
urls.py
This must be applied in your settings configuration.
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
....
] static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)