Commit 3674cdce authored by KaoruSawade's avatar KaoruSawade

Implemented editing books: created edit-book.html, edited urls.py and...

Implemented editing books: created edit-book.html, edited urls.py and views.py, & edited books_detail's button's link
parent fea21e8e
......@@ -9,7 +9,7 @@
<p>{{ book.ISBN }}</p>
<p>{{ book.blurb }}</p>
<br>
<form action='[insert link to edit-book]' >
<form action='edit' >
<input type="submit" value="Edit Book" />
</form>
<br>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form action='' method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Edit Book">
</form>
{% endblock %}
from django.urls import path
from .views import home, AuthorListView, AuthorDetailView, AuthorCreateView, BooksListView, BooksDetailView, BooksCreateView
from .views import home, AuthorListView, AuthorDetailView, AuthorCreateView, BooksListView, BooksDetailView, BooksCreateView, BooksEditView
urlpatterns = [
path('home/', home, name='home'),
......@@ -9,6 +9,7 @@ urlpatterns = [
path('books/', BooksListView.as_view(), name='books-list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name='books-detail'),
path('books/add', BooksCreateView.as_view(), name='add-book'),
path('books/<int:pk>/edit', BooksEditView.as_view(), name='edit-book'),
]
app_name = "bookshelf"
......@@ -39,3 +39,8 @@ class BooksCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class BooksEditView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
\ 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