Commit ff945914 authored by Andre Dalwin C. Tan's avatar Andre Dalwin C. Tan

Added add book and author and edit book and author html

parent d2c39a04
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Author {% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Book {% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
......@@ -9,6 +9,10 @@
<li>{{ object.age }}</li>
<li>{{ object.nationality }}</li>
<li>{{ object.bio }}</li>
<form action="./edit">
<button type="submit">Edit Author</button>
</form>
</ul>
</div>
</section>
......
......@@ -13,6 +13,11 @@
<li>{{ object.year_published }}</li>
<li>{{ object.ISBN }}</li>
<li>{{ object.blurb }}</li>
<form action="./edit">
<button type="submit">Edit Book</button>
</form>
</ul>
</div>
</section>
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Author {% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
{% endblock %}
from django.urls import path
from .views import index, BookListView, BookDetailView, AuthorListView, AuthorDetailView
from .views import index, BookListView, BookDetailView, AuthorListView, AuthorDetailView, AuthorCreateView, AuthorUpdateView, BookUpdateView, BookCreateView
urlpatterns = [
......@@ -8,5 +8,9 @@ urlpatterns = [
path('books/<int:pk>/details', BookDetailView.as_view(), name="book_detail"),
path('authors/', AuthorListView.as_view(), name="author_list"),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name="author_detail"),
path('authors/add/', AuthorCreateView.as_view(), name="new_author"),
path('authors/<int:pk>/edit', AuthorUpdateView.as_view(), name="edit_author"),
path('books/add/', BookCreateView.as_view(), name="new_book"),
path('books/<int:pk>/edit', BookUpdateView.as_view(), name="edit_book"),
]
......@@ -5,6 +5,8 @@ from .models import Author, Books
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
def index(request):
return render(request, "bookshelf/home.html",)
......@@ -17,6 +19,17 @@ class AuthorDetailView(DetailView):
template_name = 'bookshelf/authors_details.html'
model = Author
class AuthorCreateView(CreateView):
template_name = 'bookshelf/add-author.html'
model = Author
fields = '__all__'
class AuthorUpdateView(UpdateView):
template_name = 'bookshelf/edit-author.html'
model = Author
fields = '__all__'
class BookListView(ListView):
template_name = 'bookshelf/books.html'
model = Books
......@@ -25,4 +38,14 @@ class BookDetailView(DetailView):
template_name = 'bookshelf/book_details.html'
model = Books
class BookCreateView(CreateView):
template_name = 'bookshelf/add-book.html'
model = Books
fields = '__all__'
class BookUpdateView(UpdateView):
template_name = 'bookshelf/edit-book.html'
model = Books
fields = '__all__'
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