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() return HttpResponseRedirect('BRMApp/view-books')
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 = "Record stored <br> <a href='/BRMApp/view-books'>View all books</a>" return HttpResponse(s)
def editBook(request): book = models.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, 'BRMApp/edit_book.htm', {'form': form, 'book': book}) return res
def newBooks(request): form=NewBookForm() username=request.session['username'] res=render(request,'BRMApp_Template/new_book.html',{'form':form}) return res
def newBook(request): form = NewBookForm() res = render(request, 'BRMApp/new_book.htm', {'form': form}) return res