• 07.视频播放页面接口开发


    0.播放页面

    1.视频播放页面接口开发

    1.1 course/urls.py 添加路由

    router.register(r'sections', views.SectionsViewSet)

    1.2 course/serializers.py 写序列化器

    from rest_framework import serializers 
    from course.models import Sections
    
    class SectionsSerializer(serializers.ModelSerializer):
        class Meta:
            model = Sections
            fields = '__all__'

    1.3 course/views.py 添加视图函数

    from rest_framework import viewsets 
    from course.models import * 
    from course.serializers import *
    
    class SectionsViewSet(viewsets.ModelViewSet):
        queryset = Sections.objects.all()
        serializer_class = SectionsSerializer

    1.4 course/admin.py 注册后台管理

    from django.contrib import admin 
    from . import models 
    
    admin.site.register(models.Sections)

    1.5 测试接口

    • 测试接口

    • Http://192.168.56.100:8888/course/sections/

    •  返回事例

    • {
          "id": 1,
          "create_time": "2020-11-06T11:06:35.914423Z",
          "update_time": "2020-11-06T11:23:44.639999Z",
          "title": "Moity",
          "serial_num": 1,
          "learn_time": 1,
          "video": "http://192.168.56.100:8888/media/videos/20201106/8ca58c40cbdf7117943779b0ee079d7c_cxK6eSe.mp4",
          "seq_num": 1,
          "chapters": 1
      }
  • 相关阅读:
    EasyUI前后端分离
    easyUI权限
    EasyUI入门
    MVC(增删改查)
    MYSQL01 CentOS7下搭建mysql5.6
    Linux02:CentOS7配置静态IP
    Linux01:CentOS7桥接模式主机和虚拟机ping不通问题解决
    windows环境01 xampp+phpwind环境搭建
    Python模块之目录
    Django
  • 原文地址:https://www.cnblogs.com/shensy/p/13939066.html
Copyright © 2020-2023  润新知