首页 > 代码库 > 单独记录展示和历史单独记录展示

单独记录展示和历史单独记录展示

Python代码

def huixian(request, id):
    if request.method == ‘GET‘:
        id1 = id
        all_server = NginxET.objects.filter(id=id1)
        all_server1 = NginxET.objects.values_list(‘message‘, flat=True).get(id=id1)
        paginator = Paginator(all_server,10)

        try:
            page = int(request.GET.get(‘page‘,‘1‘))
        except ValueError:
            page = 1

        try:
            all_server = paginator.page(page)
        except :
            all_server = paginator.page(paginator.num_pages)
        return render_to_response(‘nginxmessage.html‘,
                     {‘all_host_list‘: all_server, ‘page‘: page, ‘paginator‘:paginator})

def huixianhistory(request, id):
    if request.method == ‘GET‘:
        id1 = id
        all_server = NginxEThistory.objects.filter(id=id1)
        all_server1 = NginxEThistory.objects.values_list(‘message‘, flat=True).get(id=id1)
        paginator = Paginator(all_server,10)

        try:
            page = int(request.GET.get(‘page‘,‘1‘))
        except ValueError:
            page = 1

        try:
            all_server = paginator.page(page)
        except :
            all_server = paginator.page(paginator.num_pages)
        return render_to_response(‘nginxhistory.html‘,
                     {‘all_host_list‘: all_server, ‘page‘: page, ‘paginator‘:paginator})

models代码

class NginxEThistory(models.Model):
    dirname = models.CharField(max_length=50, verbose_name=u‘目标地址‘)
    filename = models.CharField(max_length=100, verbose_name=u‘文件名‘)
    message = models.TextField(verbose_name=u‘nginx内容‘)
    onlinetime = models.DateTimeField(max_length=100, blank=True, verbose_name=u‘上线时间‘)

    def __unicode__(self):
        return u‘%s - %s - %s - %s‘ %(self.dirname, self.filename, self.message, self.onlinetime)

    class Meta:
        verbose_name = u‘目标地址‘
        verbose_name = u‘文件名‘

http代码展示

nginxmessage文件
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!-- Favicon -->
    <link rel="shortcut icon" href="http://www.mamicode.com/static/img/favicon.ico" type="image/x-icon">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="http://www.mamicode.com/static/plugins/bootstrap/css/bootstrap.min.css">
    <!-- Fonts from Font Awsome -->
    <link rel="stylesheet" href="http://www.mamicode.com/static/css/font-awesome.min.css">
    <!-- CSS Animate -->
    <link rel="stylesheet" href="http://www.mamicode.com/static/css/animate.css">
    <!-- Custom styles for this theme -->
    <link rel="stylesheet" href="http://www.mamicode.com/static/css/main.css">
    
    <!-- Fonts -->
    <!-- <link href=http://www.mamicode.com/‘http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,900,300italic,400italic,600italic,700italic,900italic‘ rel=‘stylesheet‘ type=‘text/css‘>"/static/js/modernizr-2.6.2.min.js"></script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="http://www.mamicode.com/static/js/html5shiv.js"></script>
    <script src="http://www.mamicode.com/static/js/respond.min.js"></script>
    <![endif]-->
</head>
      <body>
      <div class="row">
            <div class="col-md-12">
                 <div class="panel panel-default">
                      <div class="panel-body">
                           {% if all_host_list %}
                           <table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
                               <thead>
                                   <tr>
                                      <th>ID</th>
                                      <th>文件名</th>
                                      <th>回显</th>
                                   </tr>
                               </thead>

                               <tbody>
                               {% for all_host in all_host_list %}
                                   <tr>
                                      <td>{{ forloop.counter }}</td>
                                      <td>{{ all_host.filename }}</td>
                                      <td>{{ all_host.message }}</td>
                                      <td><a href="http://:8999/nginxbj/?id={{ all_host.id }}" class="btn btn-info btn-sm">编辑</a>
                                           <a href="http://www.mamicode.com/{% url ‘huixian‘ id=all_host.id %}" class="btn btn-info btn-sm">回显展示</a></td>
                                   </tr>
                               {% endfor %}
                               </tbody>
                            </table>
                           {% endif %}
                            <div class="row">
                                 <div class="col-xs-6">
                                       <div class="dataTables_info" id="example_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                                 </div>
                                 <div class="col-xs-6">
                                      <div class="dataTables_paginate paging_simple_numbers" id="exmaple_paginate">
                                           <a href="http://www.mamicode.com/{% url ‘xianip‘ %}" class="btn btn-info btn-sm" role="button">添加</a>
                                           {% if all_host_list.has_previous %}
                                                <a href="http://www.mamicode.com/?page={{ all_host_list.previous_page_number }}">上一页</a>
                                           {% endif %}
                                           <span class="current">
                                                第{{ all_host_list.number }}页,共{{ all_host_list.paginator.num_pages }}页
                                           </span>
                                           {% if all_host_list.has_next %}
                                                <a href="http://www.mamicode.com/?page={{ all_host_list.next_page_number }}">下一页</a>
                                           {% endif %}
                                      </div>
                                 </div>
                           </div> <!--row end-->
                         </div>
                     </div>
                 </div>

</body>

</html>

nginxhistory html文件

{% extends "index.html" %}
{% block title %}OMS{% endblock %}
{% block css %}
<!-- DataTables-->
<link rel="stylesheet" href="http://www.mamicode.com/static/plugins/dataTables/css/dataTables.css">
{% endblock %}
{% block content %}
      <div class="row">
            <div class="col-md-12">
                 <div class="panel panel-default">
                      <div class="panel-body">
                           {% if all_host_list %}
                           <table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
                               <thead>
                                   <tr>
                                      <th>ID</th>
                                      <th>文件名</th>
                                      <th>回显</th>
                                   </tr>
                               </thead>

                               <tbody>
                               {% for all_host in all_host_list %}
                                   <tr>
                                      <td>{{ forloop.counter }}</td>
                                      <td>{{ all_host.filename }}</td>
                                      <td>{{ all_host.message }}</td>
                                      <td><a href="http://:8999/nginxbjh/?id={{ all_host.id }}" class="btn btn-info btn-sm">编辑</a>
                                           <a href="http://www.mamicode.com/{% url ‘huixianhistory‘ id=all_host.id %}" class="btn btn-info btn-sm">回显展示</a></td>
                                   </tr>
                               {% endfor %}
                               </tbody>
                            </table>
                           {% endif %}
                            <div class="row">
                                 <div class="col-xs-6">
                                       <div class="dataTables_info" id="example_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                                 </div>
                                 <div class="col-xs-6">
                                      <div class="dataTables_paginate paging_simple_numbers" id="exmaple_paginate">
                                           <a href="http://www.mamicode.com/{% url ‘xianip‘ %}" class="btn btn-info btn-sm" role="button">添加</a>
                                           {% if all_host_list.has_previous %}
                                                <a href="http://www.mamicode.com/?page={{ all_host_list.previous_page_number }}">上一页</a>
                                           {% endif %}
                                           <span class="current">
                                                第{{ all_host_list.number }}页,共{{ all_host_list.paginator.num_pages }}页
                                           </span>
                                           {% if all_host_list.has_next %}
                                                <a href="http://www.mamicode.com/?page={{ all_host_list.next_page_number }}">下一页</a>
                                           {% endif %}
                                      </div>
                                 </div>
                           </div> <!--row end-->
                         </div>
                     </div>
                 </div>

{% endblock %}


本文出自 “学习linux” 博客,请务必保留此出处http://10265013.blog.51cto.com/10255013/1910610

单独记录展示和历史单独记录展示