Commit 44d27edb authored by Stefan Gomez's avatar Stefan Gomez

Updated the "Per Author's Details" page to add an "Edit Author" button and...

Updated the "Per Author's Details" page to add an "Edit Author" button and created the appropriate page whenever that button is clicked.
parent f4f6394a
......@@ -9,7 +9,8 @@
<h3>{{ author.nationality }}</h3>
<h3>{{ author.bio }}</h3>
<br>
<h1> Books by {{ author.first_name }} {{ author.last_name }} I love:</h1>
<a href="/authors/{{ author.pk }}/edit"><input type="submit" value="Edit Author"></a>
<br><h1> Books by {{ author.first_name }} {{ author.last_name }} I love:</h1>
<ul>
{% for book in author.book_set.all %}
<li>
......
{% 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="Save Changes">
</form>
{% endblock %}
{% block footer %}{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import home, BooksView, PerBooksView, AddBooksView, EditBooksView, AuthorsView, PerAuthorsView, AddAuthorsView
from .views import home, BooksView, PerBooksView, AddBooksView, EditBooksView, AuthorsView, PerAuthorsView, AddAuthorsView, EditAuthorsView
urlpatterns = [
......@@ -12,6 +12,7 @@ urlpatterns = [
path('authors', AuthorsView.as_view(), name='authors'),
path('authors/<int:pk>/details', PerAuthorsView.as_view(), name='author-detail'),
path('authors/add/', AddAuthorsView.as_view(), name='add-author'),
path('authors/<int:pk>/edit', EditAuthorsView.as_view(), name='edit-author'),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -46,4 +46,10 @@ class PerAuthorsView(DetailView):
class AddAuthorsView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
\ No newline at end of file
template_name = 'bookshelf/add-author.html'
class EditAuthorsView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.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