def book_add(request): if request.method is 'POST': form = BookForm(request.POST) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = BookForm() variables = RequestContext(request, {'form': form}) return render_to_response('crud/book/book_add.html', variables)
def book_add(request): if request.method is "POST": form = BookForm(request.POST) if form.is_valid(): form.save() return render_to_response("common/success.html") else: form = BookForm() variables = RequestContext(request, {"form": form}) return render_to_response("crud/book/book_add.html", variables)
def book_add(request): if request.method is 'POST': form = BookForm(request.POST) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = BookForm() variables = RequestContext(request, { 'form': form }) return render_to_response('crud/book/book_add.html', variables)
def book_edit(request, id): book = Book.objects.get(pk=id) if request.method == "POST": form = BookForm(request.POST, instance=book) if form.is_valid(): form.save() return render_to_response('common/success.html') else: form = BookForm(instance=book) variables = RequestContext(request, {'form': form}) return render_to_response("crud/book/book_edit.html", variables)
def book_edit(request, id): book = Book.objects.get(pk=id) if request.method == "POST": form = BookForm(request.POST, instance=book) if form.is_valid(): form.save() return render_to_response("common/success.html") else: form = BookForm(instance=book) variables = RequestContext(request, {"form": form}) return render_to_response("crud/book/book_edit.html", variables)