# 添加书籍: def add(reqeust): if GET请求: form=BookModelForm() return render(reqeust,{"form":form}) else POST请求: form=BookModelForm(request.POST) if form.is_valid(): form.save() # Book.objects.create(clean_data) return redirect("/") else: return render(reqeust,{"form":form}) ''' HTML渲染页面代码 '''