Djiango-靓号管理
访问靓号管理页面
-
增加表 models.py
class PrettyNum(models.Model): """靓号表""" # 如果想要为空 null=True blank=True mobile = models.CharField(verbose_name="手机号", max_length=32) price = models.IntegerField(verbose_name="价格", default=0) level_choices = ( (1, "1级"), (2, "2级"), (3, "3级"), (4, "4级"), ) level = models.SmallIntegerField(verbose_name="级别", choices=level_choices, default=1) status_choices = ( (1, "已占用"), (2, "未使用"), ) status = models.SmallIntegerField(verbose_name="状态", choices=status_choices, default=2) # INSERT INTO blog_prettynum(mobile,price,`level`,`status`) VALUES('15311111111',11111111,1,2),('15322222222',22222222,1,2),('15333333333',33333333,1,2),('15344444444',44444444,1,2),('15355555555',55555555,1,2)
- urls.py 增加访问路径 /pretty/list
# 员工管理系统-靓号管理 path('pretty/list/', pretty_list),
-
views.py 增加访问函数 pretty_list
# 靓号展示 def pretty_list(req): pretty_list = PrettyNum.objects.all().order_by("id") # 字典传参写法 # data_dict = {} # 为空则没有条件查询所有数据 # pretty_list = PrettyNum.objects.filter(**data_dict).order_by("id") # 通过get传参查询 # # http://127.0.0.1:8000/pretty/list/?q=555 data_dict = {} search_data = req.GET.get("q", "") # 有值拿值,没值为空 if search_data: data_dict["mobile__contains"] = search_data pretty_list = PrettyNum.objects.filter(**data_dict).order_by("id") # 数据比较筛选 # pretty_list = PrettyNum.objects.filter(id=12).order_by("id") # 等于 # pretty_list = PrettyNum.objects.filter(id__gt=12).order_by("id") # 大于 # pretty_list = PrettyNum.objects.filter(id__gte=12).order_by("id") # 大于等于 # pretty_list = PrettyNum.objects.filter(id__lt=12).order_by("id") # 小于 # pretty_list = PrettyNum.objects.filter(id__lte=12).order_by("id") # 小于等于 # 字符串筛选 # PrettyNum.objects.filter(mobile__startswith="1999") # 筛选出以"1999"开头的 # PrettyNum.objects.filter(mobile__endswith="1999") # 筛选出以"1999"结尾的 # PrettyNum.objects.filter(mobile__contains="1999") # 筛选出包含"1999"的 # print(pretty_list) return render(req, 'pretty_list.html', {"pretty_list": pretty_list, "search_data": search_data})
-
pretty_list.html
{% extends 'layout.html' %} {% block content %} <div class="container"> <div> <div class="row"> <div class="col-lg-6"> <div class="input-group"> <a href="/pretty/add/"> <button class="btn btn-success"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> 新增靓号-ModelForm</button> </a> </span> </div> </div> <div class="col-lg-6"> <form method="get" action="/pretty/list/"> <div class="input-group"> <input type="text" class="form-control" placeholder="查询手机号" name="q" value="{{ search_data }}"> <span class="input-group-btn"> <button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><strong> 搜索</strong></button> </span> </div> </form> </div> </div> </div> <div style="margin-top: 20px;"> <div class="panel panel-default"> <div class="panel-heading"> <strong> <span class="glyphicon glyphicon-th-list" aria-hidden="true"></span> 靓号列表 </strong> </div> <table class="table table-bordered"> <thead> <tr> <th>ID</th> <th>手机号码</th> <th>价格</th> <th>等级</th> <th>状态</th> </tr> </thead> <tbody> {% for iteam in pretty_list %} <tr> <th scope="row">{{ iteam.id }}</th> <td>{{ iteam.mobile }}</td> <td>{{ iteam.price }}</td> <td>{{ iteam.get_level_display }}</td> <td>{{ iteam.get_status_display }}</td> <td> <a class="btn btn-primary btn-xs" href="/pretty/{{ iteam.id }}/edit/"> 编辑 </a> <a class="btn btn-danger btn-xs" href="/pretty/{{ iteam.id }}/del/"> 删除 </a> </td> </tr> {% endfor %} </tbody> </table> </div> </div> </div> {% endblock %}
新增靓号
-
views.py
# from django.core.validators import RegexValidator # from django.core.exceptions import ValidationError # 新增靓号 modelform # 创建 ModelForm类 class PrettyModelForm(forms.ModelForm): # 数据验证 方式一 字段 + 正则 # from django.core.validators import RegexValidator # mobile = forms.CharField( # label="手机号", # validators=[RegexValidator(r'^1\d{10}$', '手机号格式错误')], # ) class Meta: model = PrettyNum fields = ["mobile", "price", "level", "status"] # fields = "__all__" # 所有字段 # exclude = ['level'] # 排除字段 # 循环找到所有的插件,添加 "class": "form-control" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for name, field in self.fields.items(): # 可以排除指定的字段 if name == "create_time": # widgets = { # "create_time": forms.DateTimeInput(attrs={'class': 'form-control', 'id': 'myDate', "value": "2020-01-01 00:00", "style": "width: 300px;"}), # } continue # print(name, field) field.widget.attrs = { "class": "form-control", "style": "width: 300px;", "placeholder": field.label} # 数据验证 方式二 钩子方法 # from django.core.exceptions import ValidationError def clean_mobile(self): txt_mobile = self.cleaned_data["mobile"] # 用户传入的数据 pretty_exists = PrettyNum.objects.filter(mobile=txt_mobile).exists() if pretty_exists: raise ValidationError("手机号已存在!") if len(txt_mobile) != 11: raise ValidationError("格式错误") # 验证不通过 return txt_mobile # 验证通过
- urls.py
path('pretty/add/', pretty_add),
-
pretty_add.html
{% block content %} <div class="container"> <hr> </hr> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><strong>新增靓号</strong></h3> </div> <div class="panel-body"> <form class="form-group" method="post" action="/pretty/add/" novalidate> {% csrf_token %} {% for field in form %} <div class="form-group"> <label>{{ field.label }}: </label> {{ field }} <!-- 数据校验,显示错误信息 --> <span style="color: red;">{{ field.errors.0 }}</span> </div> {% endfor %} <div class="form-group" > <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span><strong> 提 交</strong></button> </div> <br> <span style="color: red;"> {{ error_msg }} </span> </form> </div> </div> </div> {% endblock %}
编辑靓号
- urls.py
path('pretty/<int:nid>/edit/', pretty_edit),
-
views.py
# 创建pretty_edit Form类 class PrettyEditModelForm(forms.ModelForm): mobile = forms.CharField(disabled=True, label="手机号") # 禁止修改手机号 class Meta: model = PrettyNum fields = ["mobile", "price", "level", "status"] # 循环找到所有的插件,添加 "class": "form-control" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for name, field in self.fields.items(): # 可以排除指定的字段 if name == "create_time": continue # print(name, field) field.widget.attrs = { "class": "form-control", "style": "width: 300px;", "placeholder": field.label} # 创建 pretty_edit 函数 def pretty_edit(req, nid): row_obj = PrettyNum.objects.filter(id=nid).first() # GET if req.method == "GET": form = PrettyEditModelForm(instance=row_obj) return render(req, "pretty_edit.html", {"form": form, "nid": nid}) # POST form = PrettyEditModelForm(data=req.POST, instance=row_obj) if form.is_valid(): form.save() return redirect("/pretty/list/") return render(req, "pretty_edit.html", {"form": form, "nid": nid})
-
pretty_edit.html
{% block content %} <div class="container"> <hr> </hr> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><strong>编辑靓号-ModelForm</strong></h3> </div> <div class="panel-body"> <form class="form-group" method="post" action="/pretty/{{ nid }}/edit/" novalidate> {% csrf_token %} {% for field in form %} <div class="form-group"> <label>{{ field.label }}: </label> {{ field }} <!-- 数据校验,显示错误信息 --> <span style="color: red;">{{ field.errors.0 }}</span> </div> {% endfor %} <div class="form-group" > <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span><strong> 提 交</strong></button> </div> <br> <span style="color: red;"> {{ error_msg }} </span> </form> </div> </div> </div> {% endblock %}
管理分页
quertset = PrettyNum.objects.filter(id=1)[0:10]
quertset = PrettyNum.objects.all()[0:10] # 取前10条数据
quertset = PrettyNum.objects.all()[10:20] # 第二页10条数据
quertset = PrettyNum.objects.all()[20:30] # 第三页10条数据
-
views.py
# 靓号展示 def pretty_list(req): # pretty_list = PrettyNum.objects.all().order_by("id") # for i in range(99): # mobile = 15388888790 - i # price = 88888790 - i # PrettyNum.objects.create(mobile=mobile, price=price) # PrettyNum.objects.filter(mobile=mobile, price=price).delete() # 字典传参写法 # data_dict = {} # 为空则没有条件查询所有数据 # pretty_list = PrettyNum.objects.filter(**data_dict).order_by("id") # 通过get传参查询 # # http://127.0.0.1:8000/pretty/list/?q=555 data_dict = {} search_data = req.GET.get('q', "") # 有值拿值,没值为空 if search_data: data_dict["mobile__contains"] = search_data # 符合数据的总条数 total_count = PrettyNum.objects.filter(**data_dict).order_by("id").count() # 分页 page = int(req.GET.get('page', 1)) page_size = 15 start = (page - 1) * page_size end = page * page_size # 页码 # from django.utils.safestring import mark_safe total_page_count, div= divmod(total_count, page_size) if div: total_page_count += 1 # 计算显示当前页的前5页,后5页 plus = 5 # 如果数据小于等于11页时 if total_page_count <= 2 * plus +1: start_page = 1 end_page = total_page_count else: # 如果数据大于11页时 # 当前页小于等于5时 if page <= plus: start_page = 1 end_page = 2 * plus + 1 else: # 当前页大于5时 # 如果大当前页+5 > 总页码 if page + plus > total_page_count: end_page = total_page_count start_page = total_page_count - 2 * plus else: start_page = page - plus end_page = page + plus page_str_list = [] # 跳到首页 head_page = '?page={}'.format(1) # 上一页 if page == 1: prev = '<li><a href="/pretty/list/?page=1" aria-label="Previous"><span aria-hidden="true">上一页</span></a></li>' else: prev = '<li><a href="/pretty/list/?page={}" aria-label="Previous"><span aria-hidden="true">上一页</span></a></li>'.format(page - 1) page_str_list.append(prev) for i in range(start_page, end_page + 1): if i == page: ele = '<li class="active"><a href="/pretty/list/?page={}">{}<span class="sr-only">(current)</span></a></li>'.format(i, i) else: ele = '<li><a href="/pretty/list/?page={}">{}</a></li>'.format(i, i) page_str_list.append(ele) # 下一页 if page == total_page_count: next = '<li><a href="/pretty/list/?page={}" aria-label="Next"><span aria-hidden="true">下一页</span></a></li>'.format(total_page_count) else: next = '<li><a href="/pretty/list/?page={}" aria-label="Next"><span aria-hidden="true">下一页</span></a></li>'.format(page + 1) page_str_list.append(next) # 跳到尾页 end_page = '?page={}'.format(total_page_count) page_string = mark_safe("".join(page_str_list)) pretty_list = PrettyNum.objects.filter(**data_dict).order_by("id")[start:end] # 数据比较筛选 # pretty_list = PrettyNum.objects.filter(id=12).order_by("id") # 等于 # pretty_list = PrettyNum.objects.filter(id__gt=12).order_by("id") # 大于 # pretty_list = PrettyNum.objects.filter(id__gte=12).order_by("id") # 大于等于 # pretty_list = PrettyNum.objects.filter(id__lt=12).order_by("id") # 小于 # pretty_list = PrettyNum.objects.filter(id__lte=12).order_by("id") # 小于等于 # 字符串筛选 # PrettyNum.objects.filter(mobile__startswith="1999") # 筛选出以"1999"开头的 # PrettyNum.objects.filter(mobile__endswith="1999") # 筛选出以"1999"结尾的 # PrettyNum.objects.filter(mobile__contains="1999") # 筛选出包含"1999"的 # print(pretty_list) return render(req, 'pretty_list.html', {"pretty_list": pretty_list, "search_data": search_data, "page_string": page_string, "head_page": head_page, "end_page": end_page})
-
pretty_list.html
{% extends 'layout.html' %} {% block content %} <div class="container"> <div> <div class="row"> <div class="col-lg-6"> <div class="input-group"> <a href="/pretty/add/"> <button class="btn btn-success"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> 新增靓号-ModelForm</button> </a> </span> </div> </div> <div class="col-lg-6"> <form method="get" action="/pretty/list/"> <div class="input-group"> <input type="text" class="form-control" placeholder="查询手机号" name="q" value="{{ search_data }}"> <span class="input-group-btn"> <button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><strong> 搜索</strong></button> </span> </div> </form> </div> </div> </div> <div style="margin-top: 20px;"> <div class="panel panel-default"> <div class="panel-heading"> <strong> <span class="glyphicon glyphicon-th-list" aria-hidden="true"></span> 靓号列表 </strong> </div> <table class="table table-bordered"> <thead> <tr> <th>ID</th> <th>手机号码</th> <th>价格</th> <th>等级</th> <th>状态</th> </tr> </thead> <tbody> {% for iteam in pretty_list %} <tr> <th scope="row">{{ iteam.id }}</th> <td>{{ iteam.mobile }}</td> <td>{{ iteam.price }}</td> <td>{{ iteam.get_level_display }}</td> <td>{{ iteam.get_status_display }}</td> <td> <a class="btn btn-primary btn-xs" href="/pretty/{{ iteam.id }}/edit/"> 编辑 </a> <a class="btn btn-danger btn-xs" href="/pretty/{{ iteam.id }}/del/"> 删除 </a> </td> </tr> {% endfor %} </tbody> </table> </div> </div> <nav aria-label="page"> <ul class="pagination"> <li><a href="{{ head_page }}" aria-label="Previous"><span aria-hidden="true">首页</span></a></li> {{ page_string }} <li><a href="{{ end_page }}" aria-label="Next"><span aria-hidden="true">尾页</span></a></li> <form method="get" action="/pretty/list/"> <div class="input-group col-sm-2" style="display: inline-block;margin-left: 20px;"> <span class="input-group-btn"> <input type="text" class="form-control" placeholder="页面跳转" name="page"> <button class="btn btn-primary" type="submit">>> 跳转</button> </span> </div> </form> </ul> </nav> </div> {% endblock %}
分布的封装
- 封装分页 pagination.py
- pretty_list.html
<nav aria-label="page"> <ul class="pagination"> {{ page_string }} <form method="get" action="/pretty/list/"> <div class="input-group col-sm-2" style="display: inline-block;margin-left: 20px;"> <span class="input-group-btn"> <input type="text" class="form-control" placeholder="页面跳转" name="page"> <button class="btn btn-primary" type="submit">>> 跳转</button> </span> </div> </form> </ul> </nav>
-
views.py
# 靓号展示 def pretty_list(req): # 通过get传参查询 # # http://127.0.0.1:8000/pretty/list/?q=555 data_dict = {} search_data = req.GET.get('q', "") # 有值拿值,没值为空 if search_data: data_dict["mobile__contains"] = search_data # print(req.GET.get) # 分页函数封装 from blog.utils.pagination import Pagination queryset = PrettyNum.objects.filter(**data_dict).order_by("id") # 初始化封装函数 page_obj = Pagination(req, queryset) pretty_list = page_obj.page_queryset # page_string, head_page, end_page = page_obj.html() page_string = page_obj.html() context = { "pretty_list": pretty_list, "search_data": search_data, "page_string": page_string, # "head_page": head_page, # "end_page": end_page } return render(req, 'pretty_list.html', context)
"""
自定义的分页组件
"""
from django.utils.safestring import mark_safe
import copy
class Pagination(object):
def __init__(self, req, queryset, page_size=15, page_param="page", plus=5):
"""
:param req: 请求的对象
:param queryset: 符合条件的数据(根据此数据进行分页处理)
:param page_size: 每页显示多少条数据
:param page_param: 获取在URL中传递的分页参数, 例如: /pretty/list/?page=21
:param plus: 页码显示前几页后几页
"""
# 防止搜索出结果进行翻页时,URL参数没有了搜索参数
"""request.GET 对象 QueryDict类型
1.默认QueryDict不允许被修改 _mutable=False
request.GET._mutable = True
2.设置值
request.GET.setlist("q",[12]) # q=12
request.GET.setlist("page",[1, 3]) # page=1&page=1
request.GET.setlist("page",[12]) # page=1
3.调用urlencode方法,可以拼接
paramString = request.GET.urlencode()
print(paramString) "q=12&page=12"
"""
query_dict = copy.deepcopy(req.GET)
query_dict._mutable = True
self.query_dict = query_dict
print(req.GET.urlencode())
# 判断 page 页码是否合理
page = req.GET.get(page_param, "1")
if page.isdecimal():
page = int(page)
else:
page = 1
# print(page, type(page))
# # 如果不是整数
# page = int(req.GET.get(page_param, "1"))
# if type(page) != int:
# # 强制让页码为1
# page = 1
self.page_param = page_param
self.page = page
self.page_size = page_size
self.start = (page - 1) * page_size
self.end = page * page_size
# 每页展示的数据行数
self.page_queryset = queryset[self.start:self.end]
total_count = queryset.count()
total_page_count, div = divmod(total_count, page_size)
if div:
total_page_count += 1
self.total_page_count = total_page_count
self.plus = plus
def html(self):
# 计算显示当前页的前5页,后5页
# 如果数据小于等于11页时
if self.total_page_count <= 2 * self.plus + 1:
self.start_page = 1
self.end_page = self.total_page_count
else:
# 如果数据大于11页时
# 当前页小于等于5时
if self.page <= self.plus:
self.start_page = 1
self.end_page = 2 * self.plus + 1
else:
# 当前页大于5时
# 如果大当前页+5 > 总页码
if self.page + self.plus > self.total_page_count:
self.end_page = self.total_page_count
self.start_page = self.total_page_count - 2 * self.plus
else:
self.start_page = self.page - self.plus
self.end_page = self.page + self.plus
page_str_list = []
# 跳到首页
# self.head_page = '?page={}'.format(1)
self.query_dict.setlist(self.page_param, [1])
# print(self.query_dict.urlencode())
self.head_page = '<li><a href="?{}" aria-label="Previous"><span aria-hidden="true">首页</span></a></li>'.format(self.query_dict.urlencode())
page_str_list.append(self.head_page)
# 上一页
if self.page == 1:
self.query_dict.setlist(self.page_param, [1])
prev = '<li><a href="?{}" aria-label="Previous"><span aria-hidden="true">上一页</span></a></li>'.format(self.query_dict.urlencode())
else:
self.query_dict.setlist(self.page_param, [self.page - 1])
prev = '<li><a href="?{}" aria-label="Previous"><span aria-hidden="true">上一页</span></a></li>'.format(self.query_dict.urlencode())
page_str_list.append(prev)
for i in range(self.start_page, self.end_page + 1):
if i == self.page:
self.query_dict.setlist(self.page_param, [i])
ele = '<li class="active"><a href="?{}">{}<span class="sr-only">(current)</span></a></li>'.format(self.query_dict.urlencode(), i)
else:
self.query_dict.setlist(self.page_param, [i])
ele = '<li><a href="?{}">{}</a></li>'.format(self.query_dict.urlencode(), i)
page_str_list.append(ele)
# 下一页
if self.page == self.total_page_count:
self.query_dict.setlist(self.page_param, [self.total_page_count])
next = '<li><a href="?{}" aria-label="Next"><span aria-hidden="true">下一页</span></a></li>'.format(self.query_dict.urlencode())
else:
self.query_dict.setlist(self.page_param, [self.page + 1])
next = '<li><a href="?{}" aria-label="Next"><span aria-hidden="true">下一页</span></a></li>'.format(self.query_dict.urlencode())
page_str_list.append(next)
# 跳到尾页
# self.end_page = '?page={}'.format(self.total_page_count)
if self.total_page_count == 0:
self.query_dict.setlist(self.page_param, [1])
self.end_page = '<li><a href="?{}" aria-label="Next"><span aria-hidden="true">尾页</span></a></li>'.format(self.query_dict.urlencode())
else:
self.query_dict.setlist(self.page_param, [self.total_page_count])
self.end_page = '<li><a href="?{}" aria-label="Next"><span aria-hidden="true">尾页</span></a></li>'.format(self.query_dict.urlencode())
page_str_list.append(self.end_page)
self.page_string = mark_safe("".join(page_str_list))
# print(self.page_string)
# return self.page_string, self.head_page, self.end_page
return self.page_string
页面优化增加分布与搜索查询
-
部门
- views.py
def depart_list(req): # depart_list = Department.objects.all().order_by("id")
通过get传参查询
data_dict = {}
search_data = req.GET.get('title', "") # 有值拿值,没值为空
if search_data:
data_dict["title__contains"] = search_data增加分页
queryset = Department.objects.filter(**data_dict).order_by("id")
page_obj = Pagination(req, queryset)
context = {
"depart_list": page_obj.page_queryset,
"page_string": page_obj.html()
}return render(req, 'depart_list.html', context)
* depart_list.html ```html <div class="row"> <div class="col-lg-6"> <a href="/depart/add/"> <button class="btn btn-success"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> 新建部门</button> </a> </div> <div class="col-lg-6"> <form method="get" action="/depart/list/"> <div class="input-group"> <input type="text" class="form-control" placeholder="查询部门名" name="title" value="{{ search_data }}"> <span class="input-group-btn"> <button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><strong> 搜索</strong></button> </span> </div> </form> </div> </div> ....... <nav aria-label="page"> <ul class="pagination"> {{ page_string }} <form method="get" action="/depart/list/"> <div class="input-group col-sm-2" style="display: inline-block;margin-left: 20px;"> <span class="input-group-btn"> <input type="text" class="form-control" placeholder="页面跳转" name="page"> <button class="btn btn-primary" type="submit">>> 跳转</button> </span> </div> </form> </ul> </nav></code></pre> </li> <li> <h5>员工</h5> <ul> <li>views.py <pre><code class="language-py"> def users_list(req): # users_list = Employee.objects.all().order_by("id")</code></pre></li> </ul> <h1>通过get传参查询</h1> <p>data_dict = {} search_data = req.GET.get('name', "") # 有值拿值,没值为空 if search_data: data_dict["name__contains"] = search_data</p> <h1>增加分页</h1> <p>queryset = Employee.objects.filter(**data_dict).order_by("id")</p> <h1>queryset2 = Employee.objects.filter(name__contains="tang").order_by("id")</h1> <h1>print(queryset2)</h1> <p>page_obj = Pagination(req, queryset)</p> <p>context = { "users_list": page_obj.page_queryset, "page_string": page_obj.html() }</p> <p>return render(req, 'users_list.html', context)</p> <pre><code>* users_list.html ```html <div class="row"> <div class="col-lg-6"> <a href="/users/add/"> <button class="btn btn-success"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> 新建用户-原始</button> </a> <a href="/users/add_modelform/"> <button class="btn btn-success"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> 新建用户-ModelForm</button> </a> </div> <div class="col-lg-6"> <form method="get" action="/users/list/"> <div class="input-group"> <input type="text" class="form-control" placeholder="查询用户名" name="name" value="{{ search_data }}"> <span class="input-group-btn"> <button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><strong> 搜索</strong></button> </span> </div> </form> </div> </div> ........ <nav aria-label="page"> <ul class="pagination"> {{ page_string }} <form method="get" action="/users/list/"> <div class="input-group col-sm-2" style="display: inline-block;margin-left: 20px;"> <span class="input-group-btn"> <input type="text" class="form-control" placeholder="页面跳转" name="page"> <button class="btn btn-primary" type="submit">>> 跳转</button> </span> </div> </form> </ul> </nav>
- views.py