def AddBook2(request): AUTHOR = Author() AUTHOR.AulthorID = request.POST['author_ID'] AUTHOR.Age = request.POST['author_age'] AUTHOR.Country = request.POST['author_country'] AUTHOR.Name = request.POST['author_name'] AUTHOR.save() BOOK = Book() BOOK.Title = request.POST['book_name'] BOOK.AulthorID_id = request.POST['author_ID'] BOOK.Publisher = request.POST['book_publisher'] BOOK.PublishDate = request.POST['book_date'] BOOK.Price = float(request.POST['book_price']) BOOK.save() BookList = Book.objects.all() return render_to_response('BookList.html',{'BookList':BookList})
def addbook(request): title = request.POST['book_name'] #ISBN = request.POST['book_ISBN'] authorID = request.POST['book_authorID'] publisher = request.POST['book_publisher'] publishdate = request.POST['book_date'] price = request.POST['book_price'] try: author = Author.objects.get(AuthorID=authorID) BOOK = Book() BOOK.ISBN = request.POST['book_ISBN'] BOOK.Title = title BOOK.AuthorID = author BOOK.Publisher = publisher BOOK.Publishdate = publishdate BOOK.Price = float(price) BOOK.save() return render_to_response('bookinformation.html',{'booktest':BOOK}) except Author.DoesNotExist: return render_to_response('addwriter.html')
def AddBook(request): name = request.POST['book_name'] #ISBN = request.POST['book_ISBN'] authorID = request.POST['book_authorID'] publisher = request.POST['book_publisher'] date = request.POST['book_date'] price = request.POST['book_price'] try: author = Author.objects.get(AulthorID=authorID) except Author.DoesNotExist: return render_to_response('AddBook2.html',{'AulthorID':authorID,'book_name':name,'book_publisher':publisher,'book_date':date,'book_price':price}) else: BOOK = Book() #BOOK.ISBN = ISBN BOOK.Title = name BOOK.AulthorID_id = authorID BOOK.Publisher = publisher BOOK.PublishDate = date BOOK.Price = float(price) BOOK.save() lis = Author.objects.all() lis2 = Book.objects.all() return render_to_response('index.html',{'AuthorList':lis,'BookList':lis2})