Как отобразить видео из облачной галереи в панели администратора и воспроизвести его

Итак, я использую cloudinary в django для работы с видео. Работа с видео идет очень хорошо, но я хочу отображать видео на панели администратора.

models.py

course = models.ForeignKey(Course, on_delete=models.CASCADE, related_name='Course')
    public_id = models.CharField(max_length=130, blank=True, null=True)
    title = models.CharField(max_length=120)
    description = models.TextField(max_length=500, blank=True, null=True)
    thumbanil = CloudinaryField(
        "image", 
        blank=True, 
        null=True,
        public_id_prefix=get_public_id_prefix,
        display_name=get_display_name,
        tags=get_tags
    )
    video = CloudinaryField(
        "video", 
        blank=True, 
        null=True,
        type='private',
        resource_type="video",
        public_id_prefix=get_public_id_prefix,
        display_name=get_display_name,
        tags=get_tags
    )

admins.py
import helpers
from cloudinary import CloudinaryImage
from django.contrib import admin
from .models import Course, Lesson
from django.utils.html import format_html

class LessonInline(admin.StackedInline): model = Lesson fields = ['public_id', 'title', 'description', 'thumbanil', 'display_thumbnail' , 'video', 'display_video_content', 'order', 'can_preview', 'status', 'updated', 'timestamp'] readonly_fields = ['public_id', 'updated', 'timestamp', 'display_thumbnail', 'display_video_content']

    extra = 0 # means number of empty forms display in admin panel for adding lessons ok. 
def display_video_content(self, obj):
    url = helpers.get_cloudinary_video_object(
        obj,
        field_name="video",
        as_html=False,
        width=400,
        height=350,
        sign_url=False,
        fetch_format="auto",
        quality="auto"
    )
    return format_html(f"<source src='{url}' type='video/mp4' /sourse>")

display_video_content.short_description = 'Current Video'
helper/server.py

def get_cloudinary_video_object( экземпляр, field_name=«video», as_html=False, width=None, height=None, sign_url=False, # для приватных видео fetch_format=«auto», quality="auto» ): if not hasattr(instance, field_name): return «» video_objest = getattr(instance, field_name) # выдать значение fielsname экземпляра, если оно совпадает с inatance
if not video_objest: return «» video_options = { «sign_url": sign_url, «fetch_format": fetch_format, «quality": quality, } если width не None: video_options['width'] = width если высота не равна None: video_options['height'] = height если высота и ширина: video_options['crop'] = «limit» if as_html: return video_objest.image(**video_options) url = video_objest.build_url(**video_options) return url

so tell me how to display video in admin panel

i type so display image using url of video and pass in video tag img tag source tag
but video not display so could you give me example how to i display video. 

return format_html(f«<source src=„{url}“ type=„video/mp4“ /sourse>»)

sorry for my english because is little bit bad. 
Вернуться на верх