Commit 33b5ff59 authored by Mavrick Jordan Lee's avatar Mavrick Jordan Lee

Updated homepage. Added AddNewBookPage and AddNewAuthorPage.

parent 93f8fdf4
{% 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
{% extends 'base.html' %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Add Book">
</form>
{% endblock %}
\ No newline at end of file
...@@ -5,5 +5,8 @@ ...@@ -5,5 +5,8 @@
<p>Mav like Japanese manga with authors that writes in a serious tone.</p> <p>Mav like Japanese manga with authors that writes in a serious tone.</p>
<a href="{% url 'bookshelf:books' %}">Books</a> <a href="{% url 'bookshelf:books' %}">Books</a>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<a href="{% url 'bookshelf:authors' %}">Authors</a> <a href="{% url 'bookshelf:authors' %}">Authors</a><br>
<a href="{% url 'bookshelf:add-book' %}">Add Book</a>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<a href="{% url 'bookshelf:add-author' %}">Add Author</a>
{% endblock %} {% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
from .views import BooksListView, BookDetailsView, AuthorsListView, AuthorDetailsView from .views import (
BooksListView, BookDetailsView, AuthorsListView, AuthorDetailsView,
BookCreateView, AuthorCreateView
)
urlpatterns = [ urlpatterns = [
path('home/', views.home_view, name = "home"), path('home/', views.home_view, name = "home"),
...@@ -9,6 +12,8 @@ urlpatterns = [ ...@@ -9,6 +12,8 @@ urlpatterns = [
path('books/<int:pk>/details/', BookDetailsView.as_view(), name = "book-detail"), path('books/<int:pk>/details/', BookDetailsView.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 = "add-book"),
path('authors/add/', AuthorCreateView.as_view(), name = "add-author"),
] ]
app_name = 'bookshelf' app_name = 'bookshelf'
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Author, Book from .models import Author, Book
...@@ -24,3 +25,13 @@ class AuthorsListView(ListView): ...@@ -24,3 +25,13 @@ class AuthorsListView(ListView):
class AuthorDetailsView(DetailView): class AuthorDetailsView(DetailView):
model = Author model = Author
template_name = 'bookshelf/author_details.html' template_name = 'bookshelf/author_details.html'
class BookCreateView(CreateView):
model = Book
fields = '__all__'
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