def change(request): showbook=Book.objects.get(Title=request.GET['id']) if request.POST: cursor=connection.cursor() deletebook=Book.objects.get(Title=request.GET['id']) showbook = deletebook.Title deletebook.delete() Book.objects.all() cursor.close() author_list = Author.objects.all() post = request.POST new_people = Book( ISBN = post["ISBN"], Title = post["Title"], AuthorID = post["AuthorID"], Publisher = post["Publisher"], PublishDate = post["PublishDate"], Price = post["Price"], ) new_people.save() author_list = Author.objects.all() showbook = new_people return render_to_response("form3.html",{'author_list':author_list,'showbook':showbook}, context_instance=RequestContext(request)) author_list = Author.objects.all() return render_to_response("form2.html",{'author_list':author_list,'showbook':showbook}, context_instance=RequestContext(request))
def add_book(request): global ids if request.POST: post = request.POST new_people = Book( ISBN = post["ISBN"], Title = post["Title"], AuthorID = post["AuthorID"], Publisher = post["Publisher"], PublishDate = post["PublishDate"], Price = post["Price"], ) new_people.save() people_list = Book.objects.all() author_list = Author.objects.all() # c = Context({"people_list":people_list,}) #c = Context({"people_list":people_list,}) #return render_to_response("form.html",c) return render_to_response("form.html",{'people_list':people_list,'author_list':author_list,}, context_instance=RequestContext(request))