Commit 7d5898c2 authored by Eury See's avatar Eury See

Updated Book’s Details Page and Per Author’s Details Page. Added Edit Book...

Updated Book’s Details Page and Per Author’s Details Page. Added Edit Book Page and Edit Author Page.
parent 91a06345
......@@ -26,4 +26,4 @@ class Books(models.Model):
return self.title
def get_absolute_url(self):
return reverse('bookshelf:books-detail', kwargs={'pk':self.pk})
\ No newline at end of file
return reverse('bookshelf:books-detail', kwargs={'pk':self.pk})
......@@ -9,15 +9,16 @@
<h1>{{ object.first_name }} {{ object.last_name }}</h1>
</div>
<li>
{{ object.age }}
</li>
<li>
{{ object.nationality }}
</li>
<li>
{{ object.bio }}
</li>
<li>{{ object.age }}</li>
<li>{{ object.nationality }}</li>
<li>{{ object.bio }}</li>
<br>
<button type="submit">
<a href="{% url 'bookshelf:edit-author' pk=author.pk %}">Edit Author</a>
</button>
</form>
<p>Books by {{ object.first_name }} {{ object.last_name }} that I love:</p>
......
......@@ -12,6 +12,13 @@
<li> {{ object.year_published }}</li>
<li>{{ object.ISBN }}</li>
<li>{{ object.blurb }}</li>
<br>
<button type="submit">
<a href="{% url 'bookshelf:edit-book' pk=books.pk %}">Edit Book</a>
</button>
</form>
<p style="text-align: center;"><a href="http://127.0.0.1:8000/bookshelf/home">Home</a> <a href="http://127.0.0.1:8000/bookshelf/books">Books</a> <a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a></p>
......
{% extends 'bookshelf/base.html' %}
{% load static %}
{% block title %} Edit Author {% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'styles.css' %"}>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save Changes</button>
</form>
{% block styles %}
<style>
body {
background-color: #E8D1C5;
font-family: Georgia, serif;
font-size: 16px;
font-weight: bold;
color: #a77f6a;
}
</style>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'bookshelf/base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'styles.css' %"}>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save Changes</button>
</form>
{% block styles %}
<style>
body {
background-color: #cee0c2;
font-family: Georgia, serif;
font-size: 16px;
font-weight: bold;
color: #75975E;
}
</style>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (
BooksListView,BooksDetailView, AuthorListView,
AuthorDetailView, AddBooksView, AddAuthorsView)
# EditBooksView, EditAuthorsView
AuthorDetailView, AddBooksView, AddAuthorsView,
EditBooksView, EditAuthorsView)
from . import views
urlpatterns = [
......@@ -13,8 +13,8 @@ urlpatterns = [
path("authors/<int:pk>/details", AuthorDetailView.as_view(), name = "author-detail"),
path("books/add/", AddBooksView.as_view(), name = "add-book"),
path("authors/add/", AddAuthorsView.as_view(), name = "add-author"),
# path("books/<int:pk>/edit/", EditBooksView.as_view(), name = "edit-book"),
# path("authors/<int:pk>/edit/", EditAuthorsView.as_view(), name = "edit-author"),
path("books/<int:pk>/edit/", EditBooksView.as_view(), name = "edit-book"),
path("authors/<int:pk>/edit/", EditAuthorsView.as_view(), name = "edit-author"),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -48,12 +48,12 @@ class AddAuthorsView(CreateView):
fields = '__all__'
template_name = 'bookshelf/add-author.html'
# class EditBooksView(UpdateView):
# model = Author
# fields = '__all__'
# template_name = 'bookshelf/edit-book.html'
# class EditAuthorsView(UpdateView):
# model = Author
# fields = '__all__'
# template_name = 'bookshelf/edit-author.html'
\ No newline at end of file
class EditBooksView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.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