Commit 4fa16fd3 authored by Migs Atienza's avatar Migs Atienza

Added edit author html + edit author button

parent 5afc3fc9
...@@ -16,9 +16,15 @@ ...@@ -16,9 +16,15 @@
</a><br/><br/> </a><br/><br/>
</h3> </h3>
<a href="{% url 'bookshelf:edit-author' pk=object.pk %}" method="post">
{% csrf_token %}
<input type="submit" value="Edit Author">
</a>
<h2> <h2>
Books by {{ object.first_name }} {{ object.last_name}} I Love:<br/> Books by {{ object.first_name }} {{ object.last_name }} I Love:<br/>
</h2> </h2>
<ul> <ul>
{% for object in object.get_author_books %} {% for object in object.get_author_books %}
<li> <li>
......
{% extends 'base.html' %}
{% block title %}Edit Author{% endblock %}
{% block content %}<center>
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Save Changes" />
</form>
</center>
{% endblock %}
{% block links %}
<center><br/><br/><br/><br/><br/>
<a href="/bookshelf/home">Home</a>
<a href="/bookshelf/books">Books</a>
<a href="/bookshelf/authors">Authors</a></center>
{% endblock %}
\ No newline at end of file
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
<table> <table>
{{ form.as_table }} {{ form.as_table }}
</table> </table>
<input type="submit" value="Edit Book" /> <input type="submit" value="Save Changes" />
</form> </form>
</center>{% endblock %} </center>
{% endblock %}
{% block links %} {% block links %}
<center><br/><br/><br/><br/><br/> <center><br/><br/><br/><br/><br/>
<a href="/bookshelf/home">Home</a> <a href="/bookshelf/home">Home</a>
......
from django.urls import path from django.urls import path
from .views import index, home_view, BooksListView, BooksDetailView, BooksCreateView, BooksUpdateView,\ from .views import index, home_view, BooksListView, BooksDetailView, BooksCreateView, BooksUpdateView,\
AuthorsListView, AuthorsDetailView, AuthorsCreateView AuthorsListView, AuthorsDetailView, AuthorsCreateView, AuthorsUpdateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
...@@ -13,6 +13,7 @@ urlpatterns = [ ...@@ -13,6 +13,7 @@ urlpatterns = [
path('authors', AuthorsListView.as_view(), name='authors_list'), path('authors', AuthorsListView.as_view(), name='authors_list'),
path('authors/<int:pk>/details', AuthorsDetailView.as_view(), name='authors_details'), path('authors/<int:pk>/details', AuthorsDetailView.as_view(), name='authors_details'),
path('authors/add', AuthorsCreateView.as_view(), name='add_author'), path('authors/add', AuthorsCreateView.as_view(), name='add_author'),
path('authors/<int:pk>/edit', AuthorsUpdateView.as_view(), name='edit-author'),
] ]
app_name = "<bookshelf>" app_name = "<bookshelf>"
......
...@@ -51,4 +51,10 @@ class AuthorsCreateView(CreateView): ...@@ -51,4 +51,10 @@ class AuthorsCreateView(CreateView):
model = Author model = Author
fields = '__all__' fields = '__all__'
template_name = "bookshelf/add-author.html" template_name = "bookshelf/add-author.html"
class AuthorsUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = "bookshelf/edit-author.html"
# Create your views here. # Create your views here.
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