from django.db import connection from django.http import HttpReponse from .models import Book, Pulisher def index8(request): # 使用第一种方式添加一条数据 pubisher = Publisher(name='中国邮电出版社') pubisher.save() # 使用create()方法添加一条数据,使用create方法直接能够添加数据而且进行save()保存了 Publisher.objects.create(name='中国人民大学出版社') return HttpResponse("success!")