Commit 37c0c264 authored by Jan Ericsson Ong Ang's avatar Jan Ericsson Ong Ang

fixed views.py and urls.py

parent 44ba6191
from django.urls import path from django.urls import path
from .views import from .views import HomeView, AuthorView, AuthorDetailView, BooksView, BookDetailView
# url for bookshelf # url for bookshelf
urlpatterns = [ urlpatterns = [
path('', views.bookshelfIndex, name='bookshelfIndex'), path('', HomeView.as_view(), name='homepage'),
path('', views.bookshelfIndex, name='bookshelfIndex'), path('author', AuthorView.as_view(), name='author-list'),
path('', views.bookshelfIndex, name='bookshelfIndex'), path('author/<int:pk>', AuthorDetailView.as_view(), name='author-detail'),
path('boooks', BooksView.as_view(), name='books-list'),
path('books/<int:pk>', BookDetailView.as_view(), name='books-detail'),
] ]
\ No newline at end of file
...@@ -8,14 +8,6 @@ from .models import Author, Books ...@@ -8,14 +8,6 @@ from .models import Author, Books
def HomeView(request): def HomeView(request):
return render(request, 'bookshelf/home.html', {'nickname': 'Jan'}) return render(request, 'bookshelf/home.html', {'nickname': 'Jan'})
class BooksView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BookDetailsView(DetailView):
model = Books
template_name = 'bookshelf/books_details.html'
class AuthorView(ListView): class AuthorView(ListView):
model = Author model = Author
template_name = 'bookshelf/author.html' template_name = 'bookshelf/author.html'
...@@ -23,3 +15,11 @@ class AuthorView(ListView): ...@@ -23,3 +15,11 @@ class AuthorView(ListView):
class AuthorDetailView(DetailView): class AuthorDetailView(DetailView):
model = Author model = Author
template_name = 'bookshelf/author_details.html' template_name = 'bookshelf/author_details.html'
class BooksView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BookDetailView(DetailView):
model = Books
template_name = 'bookshelf/books_details.html'
\ 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