Commit 8cb26d91 authored by Ross Batacan's avatar Ross Batacan

added link Add Author on homepage and created template add-author.html

parent 679e809d
{% extends 'base.html' %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Add Author">
</form>
{% endblock %}
\ No newline at end of file
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
<br> <br> <a href="{% url 'bookshelf:book-add' %}">Add Book</a> <br> <br> <a href="{% url 'bookshelf:book-add' %}">Add Book</a>
&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
<a href="{% url 'bookshelf:author-add' %}">Add Author</a>
{% endblock %} {% endblock %}
from django.urls import path from django.urls import path
from . import views from . import views
from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView, AuthorCreateView
urlpatterns = [ urlpatterns = [
path('home/', views.home, name="home"), path('home/', views.home, name="home"),
...@@ -9,7 +9,9 @@ urlpatterns = [ ...@@ -9,7 +9,9 @@ urlpatterns = [
path('books/<int:pk>/details/', BooksDetailsView.as_view(), name="book-detail"), path('books/<int:pk>/details/', BooksDetailsView.as_view(), name="book-detail"),
path('authors/', AuthorsListView.as_view(), name="authors"), path('authors/', AuthorsListView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name="author-detail"), path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name="author-detail"),
path('books/add', BookCreateView.as_view(), name='book-add') path('books/add', BookCreateView.as_view(), name='book-add'),
path('authors/add', AuthorCreateView.as_view(), name='author-add'),
] ]
app_name = 'bookshelf' app_name = 'bookshelf'
...@@ -30,3 +30,8 @@ class BookCreateView(CreateView): ...@@ -30,3 +30,8 @@ class BookCreateView(CreateView):
model = Books model = Books
fields = '__all__' fields = '__all__'
template_name = 'bookshelf/add-book.html' template_name = 'bookshelf/add-book.html'
class AuthorCreateView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.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