Commit 372ad12e authored by Ross Batacan's avatar Ross Batacan

added Add Book link on homepage and created add-book.html

parent b5747190
......@@ -7,5 +7,9 @@
<a href="{% url 'bookshelf:books' %}">Books</a>
&nbsp&nbsp&nbsp&nbsp
<a href="{% url 'bookshelf:authors' %}">Authors</a>
&nbsp&nbsp&nbsp&nbsp
<br> <br> <a href="{% url 'bookshelf:book-add' %}">Add Book</a>
&nbsp&nbsp&nbsp&nbsp
{% endblock %}
from django.urls import path
from . import views
from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView
from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView
urlpatterns = [
path('home/', views.home, name = "home"),
path('books/', BooksListView.as_view(), name = "books"),
path('books/<int:pk>/details/', BooksDetailsView.as_view(), name = "book-detail"),
path('authors/', AuthorsListView.as_view(), name = "authors"),
path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name = "author-detail"),
path('home/', views.home, name="home"),
path('books/', BooksListView.as_view(), name="books"),
path('books/<int:pk>/details/', BooksDetailsView.as_view(), name="book-detail"),
path('authors/', AuthorsListView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name="author-detail"),
path('books/add', BookCreateView.as_view(), name='book-add')
]
app_name = 'bookshelf'
from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Author, Books
......@@ -23,4 +24,9 @@ class AuthorsListView(ListView):
class AuthorDetailsView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
\ No newline at end of file
template_name = 'bookshelf/author_details.html'
class BookCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.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