Commit f1aafed0 authored by justin's avatar justin

feat: added UpdateView for authors + buttons to edit in DetailViews

parent 4548938f
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<li>{{ object.nationality }}</li> <li>{{ object.nationality }}</li>
<li>{{ object.bio }}</li> <li>{{ object.bio }}</li>
</ul> </ul>
<a href="./edit">Edit Author</a>
</div> </div>
<div class="author-books"> <div class="author-books">
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<li>{{ object.isbn }}</li> <li>{{ object.isbn }}</li>
<li>{{ object.blurb }}</li> <li>{{ object.blurb }}</li>
</ul> </ul>
<a href="./edit">Edit Book</a>
</div> </div>
<ul class="footer"> <ul class="footer">
......
{% extends 'base.html' %}
{% block content %}
<form method="post">
{% csrf_token %} {{ form.as_p }}
<input type="submit" value="Update" />
</form>
{% endblock %}
...@@ -8,6 +8,7 @@ from .views import ( ...@@ -8,6 +8,7 @@ from .views import (
BookUpdateView, BookUpdateView,
AuthorListView, AuthorListView,
AuthorDetailView, AuthorDetailView,
AuthorUpdateView,
) )
urlpatterns = [ urlpatterns = [
...@@ -19,4 +20,5 @@ urlpatterns = [ ...@@ -19,4 +20,5 @@ urlpatterns = [
path("authors/", AuthorListView.as_view(), name="author-list"), path("authors/", AuthorListView.as_view(), name="author-list"),
path("authors/add", add_author, name="add-author"), path("authors/add", add_author, name="add-author"),
path("authors/<int:pk>/details", AuthorDetailView.as_view(), name="author-detail"), path("authors/<int:pk>/details", AuthorDetailView.as_view(), name="author-detail"),
path("authors/<int:pk>/edit", AuthorUpdateView.as_view(), name="update-author"),
] ]
...@@ -66,3 +66,9 @@ class AuthorListView(ListView): ...@@ -66,3 +66,9 @@ class AuthorListView(ListView):
class AuthorDetailView(DetailView): class AuthorDetailView(DetailView):
model = Author model = Author
template_name = "bookshelf/author_details.html" template_name = "bookshelf/author_details.html"
class AuthorUpdateView(UpdateView):
model = Author
fields = "__all__"
template_name = "bookshelf/edit-author.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