Implemented site redirection after form submission for add-book and add-author

parent 97918615
...@@ -39,9 +39,11 @@ class AddNewBookView(DetailView): ...@@ -39,9 +39,11 @@ class AddNewBookView(DetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = BookForm(request.POST) form = BookForm(request.POST)
postedauthor = Author.objects.get(pk=request.POST.get('author'))
title = request.POST.get('title') title = request.POST.get('title')
author = Author.objects.get(request.POST.get('author')) author = postedauthor
print(author)
publisher = request.POST.get('publisher') publisher = request.POST.get('publisher')
year_published = request.POST.get('year_published') year_published = request.POST.get('year_published')
ISBN = request.POST.get('ISBN') ISBN = request.POST.get('ISBN')
...@@ -66,6 +68,8 @@ class AddNewAuthorView(DetailView): ...@@ -66,6 +68,8 @@ class AddNewAuthorView(DetailView):
return render(request, 'bookshelf/add-author.html', {'form':form}) return render(request, 'bookshelf/add-author.html', {'form':form})
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = AuthorForm(request.POST)
first_name = request.POST.get('first_name') first_name = request.POST.get('first_name')
last_name = request.POST.get('last_name') last_name = request.POST.get('last_name')
age = request.POST.get('age') age = request.POST.get('age')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment