您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
直接上代码:
models.py
django.db models Asset(models.Model): OS_CHOICE = [ (, ), (, ), (, ), (, ), (, ), ] hostname = models.CharField(=, =, =) ip = models.GenericIPAddressField(=, =) port = models.IntegerField(=, =) username = models.CharField(=, =) password = models.CharField(=, =) os = models.CharField(=OS_CHOICE, =, =, =) is_active = models.BooleanField(=, =) (): .hostname
views.py
django.shortcuts get_object_or_404,render django.http HttpResponse django.views.generic ListView, CreateView, DetailView, View, UpdateView django.urls reverse_lazy django.core.paginator Paginator,EmptyPage,PageNotAnInteger .forms AssetForm .models Asset users.mixins LoginRequiredMixin page_list(request): assets = Asset.objects.all() paginator = Paginator(assets,) page = request.GET.get() page: article_list = paginator.page(page).object_list : article_list = paginator.page().object_list : customer = paginator.page(page) PageNotAnInteger: customer = paginator.page() EmptyPage: customer = paginator.page(paginator.num_pages) render(request,,{:customer,:article_list})
template模板
主机名 IP 端口 管理账号 系统 Active 操作 {% for asset in articles %} {{ asset.hostname }} {{ asset.ip }} {{ asset.port }} {{ asset.username }} {{ asset.get_os_display }} {% if not user.is_active %} 否 {% else %} {% endif %} {% endfor %} {% if cus_list.has_previous %} {% endif %} {% for pg in cus_list.paginator.page_range %} {% if cus_list.number == pg %} {{ pg }}{% else %} {{ pg }}j8-3 {% endif %} {% endfor %} {% if cus_list.has_next %} {% endif %}
效果如图:
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。