我想使用django获取存储在数据库中的视频的视频时长我拥有所有视频信息标题url pk
def post(self, request,pk):
instance = Video.objects.get(pk=pk)
form = PhotoForm(self.request.POST, self.request.FILES,instance=instance)
video_type = str(self.request.FILES.dict()["file"])[-4:]
if instance.section.course.teacher.user == request.user and form.is_valid() and video_type == ".mp4":
video_section = form.save()
data = {'is_valid': True, 'name': video_section.file.name , 'url': video_section.file.url,"pk":video_section.pk}
else:
data = {'is_valid': False}
return JsonResponse(data)