Commit 241b81e6 authored by KaoruSawade's avatar KaoruSawade

Implemented editing authors: created edit-author.html, edited urls.py and...

Implemented editing authors: created edit-author.html, edited urls.py and views.py, & edited author_detail's button's link
parent 3674cdce
......@@ -7,7 +7,7 @@
<p>{{ author.nationality }}</p>
<p>{{ author.bio }}</p>
<br>
<form action='[insert link to edit-author]' >
<form action='edit' >
<input type="submit" value="Edit Author" />
</form>
<br>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Author{% endblock %}
{% block content %}
<form action='' method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Edit Author">
</form>
{% endblock %}
from django.urls import path
from .views import home, AuthorListView, AuthorDetailView, AuthorCreateView, BooksListView, BooksDetailView, BooksCreateView, BooksEditView
from .views import home, AuthorListView, AuthorDetailView, AuthorCreateView, AuthorEditView, BooksListView, BooksDetailView, BooksCreateView, BooksEditView
urlpatterns = [
path('home/', home, name='home'),
path('authors/', AuthorListView.as_view(), name='author-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author-detail'),
path('authors/add', AuthorCreateView.as_view(), name='add-book'),
path('authors/<int:pk>/edit', AuthorEditView.as_view(), name='edit-author'),
path('books/', BooksListView.as_view(), name='books-list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name='books-detail'),
path('books/add', BooksCreateView.as_view(), name='add-book'),
......
......@@ -24,6 +24,11 @@ class AuthorCreateView(CreateView):
fields = '__all__'
template_name = 'bookshelf/add-author.html'
class AuthorEditView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
class BooksListView(ListView):
def get(self, request):
books_list = Books.objects.all()
......
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