Django application is unable to serve uploaded video files

I’m working on a Django web application that allows users to upload videos.
The videos are being saved to the correct location, as specified in the Django settings (MEDIA_ROOT and MEDIA_URL).

However, I’m facing an issue where only the first uploaded video can be played when embedded in the application’s template, while the other uploaded videos cannot be accessed directly through the URL (e.g., http://127.0.0.1:8000/media/media/video.mp4), resulting in a 404 “Page Not Found” error.

The URL patterns in my Django application appear to be correctly configured to serve the media files, and the first video can be played without any issues. But when I try to access the other uploaded videos directly through the URL, they are not found.

The thumnails generated are also saved in the correct location but are also resulting in 404 not found.

Python 3.12.3
Package Version


Django 5.0.3
django-crispy-forms 2.1
django-imagekit 5.0.0
django-js-asset 2.2.0
opencv-python 4.10.0.84
pillow 10.4.0

urls.py

from django.urls import path, include
from videos.views import videospage, upload_video
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('', videospage, name='all_videos'),
    path('videos/<str:tag_name>/', videospage, name='videos_with_tag'),
    path('upload/', upload_video, name='upload_video'),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
MEDIA_ROOT = BASE_DIR / 'src' / 'mediafiles'
MEDIA_URL = '/media/'

Where is your code for that, and what is the url of the uploaded video?
Also, post your views here.

What are the permissions there?