1.view from django.shortcuts import render,HttpResponse # Create your views here. from app01.models import * from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger def index(request): ''' 批量导入数据: Booklist=[] for i in range(100): Boo…
1. 通过切片控制分页 自定义分页: from django.shortcuts import render # Create your views here. from app01.models import Book from django.core.paginator import Paginator,EmptyPage def index(request): ''' 批量插入数据: # for i in range(100): # Book.objects.create(title="b…
1.准备数据 在models创建测试表 from django.db import models class Host(models.Model): hostname = models.CharField(max_length=32) # ip = models.GenericIPAddressField(protocol='ipv4') ip = models.CharField(max_length=32) port = models.IntegerField() 2.自动化生成数据 hos…