我正在尝试在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>
目录外观