Advertisement
Guest User

edit_book

a guest
Oct 11th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. def edit_book(request, book_id):
  2. params = {}
  3. params.update(csrf(request))
  4. params['book'] = Book.objects.get(id=book_id)
  5. params['form'] = BookForm(instance=params['book'])
  6. if request.POST:
  7. editbook_form = BookForm(request.POST, instance=params['book'])
  8. if editbook_form.is_valid():
  9. return redirect("/store/book/" + book_id + "")
  10. else:
  11. params['form'] = editbook_form
  12. else:
  13. return render_to_response('store/add_book.html', params)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement