Commit f1aafed0 authored by justin's avatar justin

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

parent 4548938f
......@@ -10,6 +10,7 @@
<li>{{ object.nationality }}</li>
<li>{{ object.bio }}</li>
</ul>
<a href="./edit">Edit Author</a>
</div>
<div class="author-books">
......
......@@ -12,6 +12,7 @@
<li>{{ object.isbn }}</li>
<li>{{ object.blurb }}</li>
</ul>
<a href="./edit">Edit Book</a>
</div>
<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 (
BookUpdateView,
AuthorListView,
AuthorDetailView,
AuthorUpdateView,
)
urlpatterns = [
......@@ -19,4 +20,5 @@ urlpatterns = [
path("authors/", AuthorListView.as_view(), name="author-list"),
path("authors/add", add_author, name="add-author"),
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):
class AuthorDetailView(DetailView):
model = Author
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