Commit 5afc3fc9 authored by Migs Atienza's avatar Migs Atienza

Added edit book html + edit book button in details

parent 07b31f40
settings.py
\ No newline at end of file
tests.py
\ No newline at end of file
......@@ -18,6 +18,10 @@
{{ object.blurb }}
</a>
</h3>
<a href="{% url 'bookshelf:edit-book' pk=object.pk %}" method="post">
{% csrf_token %}
<input type="submit" value="Edit Book">
</a>
</center>{% endblock %}
{% block links %}
<center><br/><br/><br/><br/><br/>
......
{% extends 'base.html' %}
{% block title %}Edit Book{% endblock %}
{% block content %}<center>
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Edit Book" />
</form>
</center>{% endblock %}
{% block links %}
<center><br/><br/><br/><br/><br/>
<a href="/bookshelf/home">Home</a>
<a href="/bookshelf/books">Books</a>
<a href="/bookshelf/authors">Authors</a></center>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index, home_view, BooksListView, BooksDetailView, BooksCreateView, AuthorsListView, \
AuthorsDetailView, AuthorsCreateView
from .views import index, home_view, BooksListView, BooksDetailView, BooksCreateView, BooksUpdateView,\
AuthorsListView, AuthorsDetailView, AuthorsCreateView
urlpatterns = [
path('', index, name='index'),
......@@ -9,6 +9,7 @@ urlpatterns = [
path('books', BooksListView.as_view(), name='books_list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name='books_details'),
path('books/add', BooksCreateView.as_view(), name='add_book'),
path('books/<int:pk>/edit', BooksUpdateView.as_view(), name='edit-book'),
path('authors', AuthorsListView.as_view(), name='authors_list'),
path('authors/<int:pk>/details', AuthorsDetailView.as_view(), name='authors_details'),
path('authors/add', AuthorsCreateView.as_view(), name='add_author'),
......
......@@ -31,6 +31,12 @@ class BooksCreateView(CreateView):
template_name = "bookshelf/add-book.html"
class BooksUpdateView(UpdateView):
model = Book
fields = '__all__'
template_name = "bookshelf/edit-book.html"
class AuthorsListView(ListView):
model = Author
template_name = "bookshelf/authors.html"
......
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