Commit b80b35b6 authored by Migs Atienza's avatar Migs Atienza

Added add book page

parent 4f90495d
settings.py
\ No newline at end of file
......@@ -2,7 +2,7 @@ Miguel Luis Antonio A. Atienza
210523
BS CS - DGDD
F
Lab 03: My Favorite Books and Authors
April 13, 2023
Lab 04: My Favorite Books and Authors v2
April 30, 2023
This lab requirement was made by me and only me.
<sgd> Miguel Luis Antonio A. Atienza, April 13, 2023
<sgd> Miguel Luis Antonio A. Atienza, April 30, 2023
{% extends 'base.html' %}
{% block title %}Add New Book{% endblock %}
{% block content %}<center>
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Add Book" />
</form>
</center>{% endblock %}
{% block links %}
<center><br/><br/><br/><br/><br/>
<a href="/bookshelf/home">Home</a>
<a href="/bookshelf/books">Books</a>
<a href="/bookshelf/authors">Authors</a></center>
{% endblock %}
\ No newline at end of file
......@@ -8,5 +8,7 @@ a while back. An author I enjoy here would be Rick Riordan and his Percy Jackson
{% block links %}
<center><br/><br/><br/><br/><br/>
<a href="books">Books</a>
<a>Add Book</a>
<a href="authors">Authors</a></center>
<a>Add Author</a>
{% endblock %}
from django.urls import path
from .views import index, home_view, BooksListView, BooksDetailView, AuthorsListView, AuthorsDetailView
from .views import index, home_view, BooksListView, BooksDetailView, BooksCreateView, AuthorsListView, \
AuthorsDetailView
urlpatterns = [
path('', index, name='index'),
path('home', home_view, name='home_view'),
path('books', BooksListView.as_view(), name='books_list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name='books_details'),
path('books/add', BooksCreateView.as_view(), name='add_book'),
path('authors', AuthorsListView.as_view(), name='authors_list'),
path('authors/<int:pk>/details', AuthorsDetailView.as_view(), name='authors_details'),
]
......
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
from django.http import HttpResponse
from .models import Author, Book
......@@ -24,6 +25,12 @@ class BooksDetailView(DetailView):
template_name = "bookshelf/books_details.html"
class BooksCreateView(CreateView):
model = Book
fields = '__all__'
template_name = "bookshelf/add-book.html"
class AuthorsListView(ListView):
model = Author
template_name = "bookshelf/authors.html"
......@@ -32,4 +39,7 @@ class AuthorsListView(ListView):
class AuthorsDetailView(DetailView):
model = Author
template_name = "bookshelf/authors_details.html"
# Create your views here.
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