无法在Django中加载视频

时间:2020-10-21 13:01:25

标签: python django django-models web-applications django-templates

我正在尝试在django构建的网站中播放视频,但未播放。 这是我的设置代码。

STATIC_URL = '/static/'
STATIC_DIR = os.path.join(BASE_DIR, 'static') ##lINKING THE STATIC FILES THAT IS CSS
STATICFILES_DIRS= [
       STATIC_DIR
 ]


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

Views.py

def Movie_detail(request, pk):
    post = get_object_or_404(Postmovie, pk=pk) ##EITHER gets specific object from primary key or return 404
    stuff_for_frontend = {'post': post}
    return render(request, 'Movie_Management_System/Movie_details.html',stuff_for_frontend) #render movie details

Movie_details.html

<br><br>
<video width='1000' controls> <!--video player using html-->
    <source src='{{ MEDIA_URL }}{{ videofile }}' type='video/mp4'>
</video>
<br><br>

Directory structure is like this

目录外观

enter image description here

0 个答案:

没有答案