added edit-bookpage and referenced it on views.py, models.py, and urls.py

parent 73bec87d
......@@ -39,4 +39,7 @@ class Book(models.Model):
def get_absolute_url(self):
return reverse('bookshelf:book-detail', kwargs={'pk': self.pk})
def get_edit_url(self):
return reverse('bookshelf:edit-book', kwargs={'pk' : self.pk} )
......@@ -6,14 +6,17 @@
{{object.title}}
{% endblock %}
{% block text%}
<ul><a href="{{object.author.get_absolute_url}}">{{object.author}}</a></ul>
<ul>{{object.publisher}}</ul>
<ul>{{object.year_published}}</ul>
<ul>{{object.ISBN}}</ul>
<ul>{{object.blurb}}</ul>
<ul><button onclick="document.location='{{object.get_edit_url}}'">HTML Tutorial</button></ul>
{% endblock %}
{%block hyperlinks%}
<ul><a href="{{object.author.get_absolute_url}}">{{object.author}}</a></ul>
<ul>{{object.publisher}}</ul>
<ul>{{object.year_published}}</ul>
<ul>{{object.ISBN}}</ul>
<ul>{{object.blurb}}</ul>
<br></br>
<ul><ul><a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a></ul></ul>
<ul><ul><a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a></ul></ul>
{%endblock%}
\ No newline at end of file
from django.urls import path
from .views import home_view, BookListView, AuthorsListView, BookDetailsView, AuthorDetailsView, AddBookView, AddAuthorView
from .views import home_view, BookListView, AuthorsListView, BookDetailsView, AuthorDetailsView, AddBookView, AddAuthorView, EditBookView
urlpatterns = [
path('', home_view, name="My Favorite Books & Authors"),
......@@ -12,6 +12,7 @@ urlpatterns = [
path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name ="author-detail"),
path('books/add/', AddBookView.as_view(), name ="add-book"),
path('books/<int:pk>/edit/', EditBookView.as_view(), name ="edit-book"),
path('authors/add/', AddAuthorView.as_view(), name ="add-author"),
]
......
......@@ -34,7 +34,6 @@ class AuthorDetailsView(DetailView):
return context
class AddBookView(CreateView):
model = Book
fields = '__all__'
......@@ -43,4 +42,10 @@ class AddBookView(CreateView):
class AddAuthorView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
\ No newline at end of file
template_name = 'bookshelf/add-author.html'
class EditBookView(UpdateView):
model = Book
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