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 @@
&nbsp&nbsp&nbsp&nbsp
<br> <br> <a href="{% url 'bookshelf:book-add' %}">Add Book</a>
&nbsp&nbsp&nbsp&nbsp
{% endblock %}
<a href="{% url 'bookshelf:author-add' %}">Add Author</a>
{% endblock %}
from django.urls import path
from . import views
from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView
from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView, AuthorCreateView
urlpatterns = [
path('home/', views.home, name="home"),
......@@ -9,7 +9,9 @@ urlpatterns = [
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')
path('books/add', BookCreateView.as_view(), name='book-add'),
path('authors/add', AuthorCreateView.as_view(), name='author-add'),
]
app_name = 'bookshelf'
......@@ -29,4 +29,9 @@ class AuthorDetailsView(DetailView):
class BookCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
\ No newline at end of file
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