一、视频页面功能开发
在app文件夹的views文件夹中,创建一个video文件。再在templates文件夹下的dashboard文件夹下建一个video文件夹,方video页面。
video.py中
# coding:utf-8
from django.shortcuts import redirect, reverse
from django.views import View
from app.libs.base_render import render_to_response # mako的render
from app.utils.permission import dashboard_auth # 登录验证
class ExternalVideo(View):
TEMPLATE = 'dashboard/video/external_video.html'
@dashboard_auth
def get(self, request):
return render_to_response(request, self.TEMPLATE)
配置路由
from .views.video import ExternalVideo
path('video/external', ExternalVideo.as_view(), name='external_video')
然后在base.html中,加上外链视频的链接<li><a href="${reverse('external_video')}">外链视频</a></li>
然后写外链视频的页面:
external_video.html中:
<%inherit file="../base.html" />
<%! from django.shortcuts import reverse %>
<%def name="content()">
<%
from app.model.video import VideoType, FromType, NationalityType
%>
<h1>外链视频</h1>
<button class="btn btn-info open-btn">创建</button>
<form class="form-horizontal edit-area add-video-area" action="" method="post">
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="name" class="form-control" placeholder="视频名称">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" name="name" class="form-control" placeholder="海报">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>视频类型</label>
<select class="form-control video-select">
%for video_type in VideoType:
<option value="${video_type.value}">${video_type.label}</option>
%endfor
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>视频来源</label>
<select class="form-control video-select">
%for from_to in FromType:
%if from_to != FromType('custom'):
<option value="${from_to.value}">${from_to.label}</option>
%endif
%endfor
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>视频国籍</label>
<select class="form-control video-select">
%for nationality in NationalityType:
<option value="${nationality.value}">${nationality.label}</option>
%endfor
</select>
</div>
</div>
<button type="submit" class="btn btn-info">添加</button>
</form>
</%def>
<%def name="css()">
<link href="/static/dashboard/css/external_video.css" rel="stylesheet" />
</%def>
<%def name="js()">