def edit(request): if request.method == 'POST': form = NewBookForm(request.POST) book = Book() book.id = request.POST['bookid'] book.title = form.data['title'] book.price = form.data['price'] book.author = form.data['author'] book.publisher = form.data['publisher'] book.save() return HttpResponseRedirect('BRM/view_book.html')
def add(request): if request.method == 'POST': form = NewBookForm(request.POST) book = Book() book.title = form.data['title'] book.price = form.data['price'] book.author = form.data['author'] book.publisher = form.data['publisher'] book.save() s = "Recored stored successfully<br><a href='BRM/view_book'>View All Book</a>" return HttpResponse(s)
def editBook(request): book = Book.objects.get(id=request.GET['bookid']) fields = { 'title': book.title, 'price': book.price, 'author': book.author, 'publisher': book.publisher } form = NewBookForm(initial=fields) res = render(request, 'BRM/edit_book.html', {'form': form, 'book': book}) return res
def add(request): if request.method == 'POST': form = NewBookForm(request.POST) book = models.Book() book.title = form.data['title'] book.price = form.data['price'] book.author = form.data['author'] book.publisher = form.data['publisher'] book.save() s = "Redord Stored<br><a href='/BRM/view-books'>View all Books</a>" return HttpResponse(s)
def newBook(request): form = NewBookForm() res = render(request, 'BRM/new_book.html', {'form': form}) return res