def add_Author(request): if request.method =="POST": form = newAuthor(request.POST) if form.is_valid(): cd = form.cleaned_data a = Author(ID = cd["ID"], Name = cd["Name"], Age = cd["Age"], Country = cd["Country"] ) a.save() b = Book.objects.get(ISBN = request.GET.get("ISBN")) b.AuthorID = a b.save() return HttpResponseRedirect("/success/") else: form = newAuthor(initial ={'Name':request.GET.get("author")}) return render_to_response("add_author.html",{"form":form,"author":request.\ GET.get("author")})
def add_author(request): if request.method =="POST": form = newAuthor(request.POST) if form.is_valid(): cd = form.cleaned_data a = Author(ID = cd["ID"], Name = cd["Name"], Age = cd["Age"], Country = cd["Country"] ) a.save() b = Book(ISBN = request.session["ISBN"], Title = request.session["Title"], AuthorID = a, Publisher = request.session["Publisher"], PublishDate = request.session["PublishDate"], Price = (float)(request.session["Price"]) ) b.save() return HttpResponseRedirect("/success/") else: form = newAuthor(initial ={'Name':request.GET.get("author")}) return render_to_response("add_author.html",{"form":form,"author":\ request.GET.get("author")})