Update details html, complete edit htmls, finalize views and urls

parent 10d95ab3
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
{{author.nationality}} <br /> {{author.nationality}} <br />
{{author.bio}} <br /> {{author.bio}} <br />
<button onclick="window.location.href='../../../books/{{author.id}}/edit/';">Edit Author</button> <br />
Books by {{author.first_name}} {{author.last_name}} I love: Books by {{author.first_name}} {{author.last_name}} I love:
<ul> <ul>
{% for object in books %} {% for object in books %}
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
{{book.isbn}} <br /> {{book.isbn}} <br />
{{book.blurb}} <br /> {{book.blurb}} <br />
</p> </p>
<button onclick="window.location.href='../../../books/{{book.id}}/edit/';">Edit Book</button>
<p class = "unaligned_paragraph"> <p class = "unaligned_paragraph">
<br /> <br />
<br /> <br />
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}Add New Author{% 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
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}Add New 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
...@@ -9,8 +9,8 @@ urlpatterns = [ ...@@ -9,8 +9,8 @@ urlpatterns = [
path('authors/<int:author_id>/details/', views.authordetails_view.as_view(), name='author_details'), path('authors/<int:author_id>/details/', views.authordetails_view.as_view(), name='author_details'),
path('books/add', views.addbooks_view.as_view(), name='add_book'), path('books/add', views.addbooks_view.as_view(), name='add_book'),
path('authors/add', views.addauthors_view.as_view(), name='add_author'), path('authors/add', views.addauthors_view.as_view(), name='add_author'),
#path('books//<int:book_id>/edit/', views_editbook_view.as_view(), name='edit_book'), path('books/<int:pk>/edit/', views.editbooks_view.as_view(), name='edit_book'),
#path('books//<int:author_id>/edit/', views_editauthor_view.as_view(), name='edit_author'), path('books/<int:pk>/edit/', views.editauthors_view.as_view(), name='edit_author'),
] ]
app_name = "bookshelf" app_name = "bookshelf"
\ No newline at end of file
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView, UpdateView
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.shortcuts import render from django.shortcuts import render
from django.views import View from django.views import View
...@@ -49,3 +49,13 @@ class addauthors_view(CreateView): ...@@ -49,3 +49,13 @@ class addauthors_view(CreateView):
model = Author model = Author
fields = '__all__' fields = '__all__'
template_name = 'bookshelf/add-author.html' template_name = 'bookshelf/add-author.html'
class editbooks_view(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
class editauthors_view(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