Commit 4548938f authored by justin's avatar justin

feat: added UpdateView for books

parent 2e61b8dd
{% extends 'base.html' %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update" />
</form>
{% endblock %}
......@@ -5,6 +5,7 @@ from .views import (
add_author,
BookListView,
BookDetailView,
BookUpdateView,
AuthorListView,
AuthorDetailView,
)
......@@ -14,6 +15,7 @@ urlpatterns = [
path("books/", BookListView.as_view(), name="book-list"),
path("books/<int:pk>/details", BookDetailView.as_view(), name="book-detail"),
path("books/add", add_book, name="add-book"),
path("books/<int:pk>/edit", BookUpdateView.as_view(), name="update-book"),
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"),
......
......@@ -2,6 +2,7 @@ from django.shortcuts import render, redirect
from django.urls import reverse
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import UpdateView
from .models import Author, Books
from .forms import AuthorForm, BookForm
......@@ -50,6 +51,12 @@ class BookDetailView(DetailView):
template_name = "bookshelf/book_details.html"
class BookUpdateView(UpdateView):
model = Books
fields = "__all__"
template_name = "bookshelf/edit-book.html"
class AuthorListView(ListView):
model = Author
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