Commit 139b0a03 authored by Sharmaine Chua's avatar Sharmaine Chua

added form pages and edited the template file

parent 46b8410e
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<div class="add-author">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<div class="add_book">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Submit</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
......@@ -18,6 +18,9 @@
<a href="../authors">
<button type="button"><p>Authors</p></button>
</a>
<br>
<a href="../books/add">Add Book</a>
<a href="../authors/add">Add Author</a>
</div>
</center>
{% endblock %}
\ No newline at end of file
......@@ -7,6 +7,8 @@ urlpatterns = [
path('books/<int:pk>/details',BooksDetailView.as_view(),name='book_details'),
path('authors/',AuthorListView.as_view(),name='author_list'),
path('authors/<int:pk>/details',AuthorDetailView.as_view(),name='author_details'),
path('books/add',BooksCreateView.as_view(),name='create_book'),
path('authors/add',AuthorCreateView.as_view(),name='new_author'),
]
app_name = 'bookshelf'
\ No newline at end of file
......@@ -2,6 +2,7 @@ from django.shortcuts import render
from django.http import HttpResponse, request
from django.views import View
from .models import Author, Books
from django.views.generic.edit import CreateView
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
......@@ -17,10 +18,20 @@ class BooksDetailView(DetailView):
model = Books
template_name='bookshelf/book_details.html'
class BooksCreateView(CreateView):
model = Books
template_name = 'bookshelf/add-book.html'
fields = '__all__'
class AuthorListView(ListView):
model = Author
template_name='bookshelf/authors.html'
class AuthorDetailView(DetailView):
model = Author
template_name='bookshelf/author_details.html'
\ No newline at end of file
template_name='bookshelf/author_details.html'
class AuthorCreateView(CreateView):
model = Author
template_name = 'bookshelf/add-author.html'
fields = '__all__'
\ 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