Commit b7f60669 authored by Julia Anishka's avatar Julia Anishka

added eedit book page

parent 90517f7d
......@@ -20,6 +20,7 @@
<h4> ISBN: {{ object.ISBN }} </h4>
<p> Blurb: {{ object.blurb }} </p>
<div class="btns">
<a href="{{ object.get_absolute_url }}edit" class="btn"> Edit Book </a>
<a href="/home/" class="btn"> Home </a>
<a href="/books/" class="btn"> Books </a>
<a href="/authors/" class="btn"> Authors </a>
......
{% extends 'base.html' %}
{% block title %} Edit Book {% endblock %}
{% block body %}
<form method='POST'>
{% csrf_token %}
{{ form }}
<input type='Submit' value='Save Changes'>
</form>
{% endblock %}
\ No newline at end of file
......@@ -2,13 +2,14 @@ from django.urls import path
from . import views
from .views import (BooksListView, BooksDetailView, BooksCreateView, AuthorsListView,
AuthorsDetailView, AuthorsCreateView, )
AuthorsDetailView, AuthorsCreateView, BooksUpdateView)
urlpatterns = [
path('home/', views.homepage_view, name='home'),
path('books/', BooksListView.as_view(), name='books'),
path('books/<int:pk>/details/', BooksDetailView.as_view(), name='book_details'),
path('home/books/add/', BooksCreateView.as_view(), name='add-book'),
path('books/<int:pk>/details/edit/', BooksUpdateView.as_view(), name='edit-book'),
path('authors/', AuthorsListView.as_view(), name='authors'),
path('authors/<int:pk>/details/', AuthorsDetailView.as_view(), name='author_details'),
path('home/authors/add/', AuthorsCreateView.as_view(), name='add-author'),
......
......@@ -3,7 +3,7 @@ from django.http import HttpResponse
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from django.views.generic.edit import CreateView, UpdateView
from .models import Author, Books
from .forms import BooksForm, AuthorForm
......@@ -66,6 +66,11 @@ class BooksCreateView(CreateView):
template_name = 'bookshelf/add-book.html'
fields = '__all__'
class BooksUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
class AuthorsListView(ListView):
model = Author
template_name = 'bookshelf/authors.html'
......@@ -78,4 +83,3 @@ class AuthorsCreateView(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