Commit b7f60669 authored by Julia Anishka's avatar Julia Anishka

added eedit book page

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