Commit 44333974 authored by Ross Batacan's avatar Ross Batacan

added edit feature on book_details.html and created template edit-book.html

parent 8cb26d91
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
{{ books.blurb }}<br> {{ books.blurb }}<br>
</p> </p>
<a href="{% url 'bookshelf:book-edit' books.id %}"><button>Edit</button></a>
<br><br>
<a href="{% url 'bookshelf:home' %}">Home</a> <a href="{% url 'bookshelf:home' %}">Home</a>
&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
<a href="{% url 'bookshelf:books' %}">Books</a> <a href="{% url 'bookshelf:books' %}">Books</a>
&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
<a href="{% url 'bookshelf:authors' %}">Authors</a> <a href="{% url 'bookshelf:authors' %}">Authors</a>
{% endblock %} {% endblock %}
{% extends 'base.html' %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="Submit" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView, AuthorCreateView from .views import BooksListView, BooksDetailsView, AuthorsListView, AuthorDetailsView, BookCreateView, AuthorCreateView, BookEditView
urlpatterns = [ urlpatterns = [
path('home/', views.home, name="home"), path('home/', views.home, name="home"),
...@@ -11,6 +11,7 @@ urlpatterns = [ ...@@ -11,6 +11,7 @@ urlpatterns = [
path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name="author-detail"), path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name="author-detail"),
path('books/add', BookCreateView.as_view(), name='book-add'), path('books/add', BookCreateView.as_view(), name='book-add'),
path('authors/add', AuthorCreateView.as_view(), name='author-add'), path('authors/add', AuthorCreateView.as_view(), name='author-add'),
path('books/<int:pk>/edit/', BookEditView.as_view(), name='book-edit'),
] ]
......
...@@ -34,4 +34,9 @@ class BookCreateView(CreateView): ...@@ -34,4 +34,9 @@ class BookCreateView(CreateView):
class AuthorCreateView(CreateView): class AuthorCreateView(CreateView):
model = Author model = Author
fields = '__all__' fields = '__all__'
template_name = 'bookshelf/add-author.html' template_name = 'bookshelf/add-author.html'
\ No newline at end of file
class BookEditView(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