Commit 43847e19 authored by Deokhyun Lee's avatar Deokhyun Lee

fixed the url pattern name

parent 75caf9b9
from django import forms
from .models import Author, Books
from .models import Books
class AddBookForm(forms.Form):
class AddBookForm(forms.ModelForm):
class Meta:
model = Books
fields = '__all__'
def save(self, commit=True):
book = super().save(commit=False)
# Do any additional processing of the form data here
if commit:
book.save()
return book
# def save(self, commit=True):
# book = super().save(commit=False)
# # Do any additional processing of the form data here
# if commit:
# book.save()
# return book
......@@ -6,9 +6,9 @@ urlpatterns = [
path('home/', HomeView.as_view(), name='home'),
# for Authors page
path('authors/', AuthorListView.as_view(), name='authors'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author-detail'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author_detail'),
# for Books page
path('books/', BookListView.as_view(), name='books'),
path('books/<int:pk>/details', BookDetailView.as_view(), name='book-detail'),
path('books/add',BookAddListView.as_view(), name="add-book" )
path('books/<int:pk>/details', BookDetailView.as_view(), name='book_detail'),
path('books/add',BookAddListView.as_view(), name="add_book" )
]
\ No newline at end of file
......@@ -53,6 +53,6 @@ class BookAddListView(CreateView):
# onSave is called, the form will have essential data and this includes pk as well.
new_book = form.save()
# pass the pk
return redirect('subject_detail', pk = new_book.pk)
return redirect('book-details', pk = new_book.pk)
else:
return render(request, 'subject_detail.html', {'form': form})
\ No newline at end of file
return render(request, 'book_details.html', {'form': form})
\ No newline at end of file
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