Commit 173cca92 authored by Stefan Gomez's avatar Stefan Gomez

Added a link to add authors in the Homepage and created the appropriate "Add...

Added a link to add authors in the Homepage and created the appropriate "Add New Authors" page respectively.
parent b412220b
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Add Author">
</form>
{% endblock %}
{% block footer %}{% endblock %}
\ No newline at end of file
......@@ -11,5 +11,5 @@ To be honest I am not really a book kind of guy. Why read a book when you can ju
{% block footer %}
<a href="/books">Books</a> | <a href="/authors">Authors
<br><a href="/books/add">Add Book</a>
<br><a href="/books/add">Add Book</a> | <a href="/authors/add">Add Author</a>
</a>{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import home, BooksView, PerBooksView, AddBooksView, AuthorsView, PerAuthorsView
from .views import home, BooksView, PerBooksView, AddBooksView, AuthorsView, PerAuthorsView, AddAuthorsView
urlpatterns = [
......@@ -9,7 +9,8 @@ urlpatterns = [
path('books/<int:pk>/details', PerBooksView.as_view(), name='book-detail'),
path('books/add/', AddBooksView.as_view(), name='add-book'),
path('authors', AuthorsView.as_view(), name='authors'),
path('authors/<int:pk>/details', PerAuthorsView.as_view(), name='author-detail')
path('authors/<int:pk>/details', PerAuthorsView.as_view(), name='author-detail'),
path('authors/add/', AddAuthorsView.as_view(), name='add-author'),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -34,3 +34,9 @@ class AuthorsView(ListView):
class PerAuthorsView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
class AddAuthorsView(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