# 批量创建数据

# Create your views here.
from django.db import models
from django.shortcuts import HttpResponse
from .models import Book import random def index(request):
lst = []
for i in range(102,131):
book=Book(title="book_%s"%i,price=random.randint(1,999))
lst.append(book) Book.objects.bulk_create(lst) return HttpResponse("ok")
05-20 08:36