django 给数据库批量添加数据
from .models import Book
import random
def index(request): book_list = [] for i in range(1, 101): book = Book(title="book_%s" % i,price=random.randint(1, 599)) book_list.append(book) Book.objects.bulk_create(book_list) #批量往数据库中创建数据
普通人!