Commit 5831d3d3 authored by Javi Ng's avatar Javi Ng

modified views and urls to add update and create pages, created initial html...

modified views and urls to add update and create pages, created initial html files for update and create pages
parent 157ace1b
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Author {% endblock %}
{% block content %}
<form method="POST" action="newauthor">
{% csrf_token %}
{{ form }}
<input type="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Book {% endblock %}
{% block content %}
<form method="POST" action="newbook">
{% csrf_token %}
{{ form }}
<input type="Submit">
</form>
{% endblock %}
\ No newline at end of file
......@@ -5,6 +5,10 @@ urlpatterns = [
path('home/', views.HomeView, name = "home"),
path('books/', views.BookListView.as_view(), name="booklist"),
path('books/<int:pk>/details', views.BookDetailView.as_view(), name="bookdetail"),
path('books/add/', views.BookCreateView.as_view(), name="newbook"),
path('books/<int:pk>/details', views.BookUpdateView.as_view(), name="updatebook"),
path('authors/', views.AuthorListView.as_view(), name="authorlist"),
path('authors/<int:pk>/details', views.AuthorDetailView.as_view(), name="authordetail"),
path('authors/add/', views.AuthorCreateView.as_view(), name="newauthor"),
path('authors/<int:pk>/details', views.AuthorUpdateView.as_view(), name="updateauthor"),
]
\ No newline at end of file
......@@ -3,6 +3,7 @@ from django.shortcuts import render
from .models import Author, Book
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
# Create your views here.
def HomeView(request):
......@@ -16,10 +17,30 @@ class BookDetailView(DetailView):
template_name = 'bookshelf/book_details.html'
model = Book
class BookCreateView(CreateView):
template_name = 'bookshelf/add_book.html'
model = Book
fields = '__all__'
class BookUpdateView(UpdateView):
template_name = 'bookshelf/edit_book.html'
model = Book
fields = '__all__'
class AuthorListView(ListView):
template_name = 'bookshelf/authors.html'
model = Author
class AuthorDetailView(DetailView):
template_name = 'bookshelf/author_details.html'
model = Author
\ No newline at end of file
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__'
\ 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