Commit 2f4a2e67 authored by Nate Brevin A. Que's avatar Nate Brevin A. Que

Updated the Homepage to include a link to add authors and Implemented the 'Add...

Updated the Homepage to include a link to add authors and Implemented the 'Add New Author' page using CreateView and configuring urls.py
parent ca00dce6
{% extends 'base.html' %}
{% 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 scripts %}
{% endblock %}
\ No newline at end of file
......@@ -17,4 +17,5 @@
<a href="/books">Books</a>
<a href="/authors">Authors</a><br>
<a href="/books/add">Add Book</a>
<a href="/authors/add">Add Author</a>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (homepage_view, BooksListView, BooksDetailView, BooksCreateView,
AuthorListView, AuthorDetailView)
AuthorListView, AuthorDetailView, AuthorCreateView)
urlpatterns = [
path('home/', homepage_view, name='home'),
......@@ -10,6 +10,7 @@ urlpatterns = [
path('books/add/', BooksCreateView.as_view(), name='add-book'),
path('authors/', AuthorListView.as_view(), name='authors-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author-details'),
path('authors/add/', AuthorCreateView.as_view(), name='add-author'),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -29,6 +29,7 @@ class BooksCreateView(CreateView):
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class AuthorListView(ListView):
model = Author
......@@ -41,3 +42,9 @@ class AuthorDetailView(DetailView):
def get(self, request, pk):
return render(request, 'bookshelf/author_details.html', {'author': self.model.objects.get(pk=pk)})
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