Commit 1b3ac646 authored by Almira Redoble's avatar Almira Redoble

Created views and templates for Edit Book and Edit Author pages. Configured...

Created views and templates for Edit Book and Edit Author pages. Configured their urls afterwards. Also edited book detail and author detail pages to include 'edit book' and 'edit author' buttons, respectively.
parent 53f031ac
......@@ -12,6 +12,8 @@ https://www.w3schools.com/howto/howto_css_list_without_bullets.asp
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
https://www.w3schools.com/css/css_text.asp
https://www.w3schools.com/css/css_border.asp
https://www.w3docs.com/snippets/html/how-to-create-an-html-button-that-acts-like-a-link.html
https://levelup.gitconnected.com/django-quick-tips-get-absolute-url-1c22321f806b
Authors:
https://en.wikipedia.org/wiki/Magdalena_Jalandoni
......
......@@ -22,6 +22,10 @@
</li>
</ul>
<form action="{% url 'bookshelf:author-edit' pk=object.pk %}">
<input type="submit" value="Edit Author">
</form>
<h2>Books by {{ object }} I love:</h2>
<ul>
{% for book in object.books.all %}
......
......@@ -27,6 +27,11 @@
{{ object.blurb }}
</li>
</ul>
<form action="{% url 'bookshelf:book-edit' pk=object.pk %}">
<input type="submit" value="Edit Book">
</form>
{% endblock %}
{% block footer %}
......
{% extends 'base.html' %}
{% load static %}
{% block title %}
Edit Book
{% endblock %}
{% block heading %}
Edit {{ object.title }}
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
<form action="{% url 'bookshelf:author-edit' pk=object.pk %}" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Save Changes">
</form>
{% endblock %}
{% block footer %}
<a href="{% url 'bookshelf:home' %}">Home</a>
<a href="{% url 'bookshelf:books' %}">Books</a>
<a href="{% url 'bookshelf:authors' %}">Authors</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}
Edit Book
{% endblock %}
{% block heading %}
Edit {{ object.title }}
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
<form action="{% url 'bookshelf:book-edit' pk=object.pk %}" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Save Changes">
</form>
{% endblock %}
{% block footer %}
<a href="{% url 'bookshelf:home' %}">Home</a>
<a href="{% url 'bookshelf:books' %}">Books</a>
<a href="{% url 'bookshelf:authors' %}">Authors</a>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (
HomePageView, BookListView, BookDetailView, AuthorListView,
AuthorDetailView, BookCreateView, AuthorCreateView
AuthorDetailView, BookCreateView, AuthorCreateView,
BookUpdateView, AuthorUpdateView
)
urlpatterns = [
......@@ -12,6 +13,8 @@ urlpatterns = [
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author-details'),
path('books/add', BookCreateView.as_view(), name='books-add'),
path('authors/add', AuthorCreateView.as_view(), name='authors-add'),
path('books/<int:pk>/edit', BookUpdateView.as_view(), name='book-edit'),
path('authors/<int:pk>/edit', AuthorUpdateView.as_view(), name='author-edit'),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -32,6 +32,11 @@ class BookCreateView(CreateView):
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class BookUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
class AuthorListView(ListView):
model = Author
template_name = 'bookshelf/authors.html'
......@@ -43,4 +48,9 @@ class AuthorDetailView(DetailView):
class AuthorCreateView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
\ No newline at end of file
template_name = 'bookshelf/add-author.html'
class AuthorUpdateView(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