Commit 3067da52 authored by Gabriel G. Garrero's avatar Gabriel G. Garrero

Created add author button in author_details.html, created edit-author.html,...

Created add author button in author_details.html, created edit-author.html, updated views.py and urls.py to account for edit author function
parent 945ae307
......@@ -12,6 +12,10 @@
<p>{{ object.nationality }}</p>
<p>{{ object.bio }}</p>
<form action = "./edit">
<input type = "submit" value = "Edit Author">
</form>
<h2>Books by {{ object.first_name }} {{ object.last_name }} I love:</h2>
<ul>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Author{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>{{ field.label }} has the following errors:</p>
<ul>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<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, BooksCreateView, BooksUpdateView,
AuthorListView, AuthorDetailView, AuthorCreateView
AuthorListView, AuthorDetailView, AuthorCreateView, AuthorCreateView
)
urlpatterns = [
......@@ -13,6 +13,7 @@ urlpatterns = [
path('authors/', AuthorListView.as_view(), name = 'author-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'),
path('authors/add', AuthorCreateView.as_view(), name = 'add-author'),
path('authors/<int:pk>/edit', AuthorCreateView.as_view(), name = 'edit-author'),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -38,3 +38,8 @@ class AuthorCreateView(CreateView):
model = Author
template_name = 'bookshelf/add-author.html'
fields = '__all__'
class AuthorUpdateView(UpdateView):
model = Author
template_name = 'bookshelf/edit-author.html'
fields = '__all__'
\ 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