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

Added edit book html + edit book button in details

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