Commit 4fa69934 authored by Trisha Angel Millena's avatar Trisha Angel Millena

Edited views.py: Added BooksUpdateView, Edited urls.py: added...

Edited views.py: Added BooksUpdateView, Edited urls.py: added path('books/<int:pk>/edit/, Created edit-book.html
parent f4dd66f1
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit 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 .views import (home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView, BooksCreateView, AuthorCreateView)
from .views import (home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView, BooksCreateView, AuthorCreateView, BooksUpdateView)
urlpatterns = [
path('home/', home, name = 'home'),
......@@ -10,6 +10,7 @@ urlpatterns = [
path('books/add/', BooksCreateView.as_view(), name = "add-book"),
path('authors/add/', AuthorCreateView.as_view(), name = "add-author"),
path('books/<int:pk>/edit/', BooksUpdateView.as_view(), name = "edit-book")
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -34,4 +34,9 @@ class BooksCreateView(CreateView):
class AuthorCreateView(CreateView):
model = Author
fields = "__all__"
template_name = 'bookshelf/add-author.html'
\ No newline at end of file
template_name = 'bookshelf/add-author.html'
class BooksUpdateView(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