Commit 86f3754b authored by EJ Mejilla's avatar EJ Mejilla

Added Edit Views for Author and Book models

parent 35dca3f6
lab3env/
lab4env/
.env
db.sqlite3
__pycache__/
......@@ -12,6 +12,11 @@
</ul>
</div>
<a href="{% url 'bookshelf:author-update' pk=object.pk %}" method="post">
{% csrf_token %}
<input type="submit" value="Edit Author">
</a>
<div>
<h2>Books by {{object.first_name}} {{object.last_name}} I love:</h2>
<ul>
......
......@@ -14,6 +14,11 @@
</ul>
</div>
<a href="{% url 'bookshelf:book-update' pk=object.pk %}" method="post">
{% csrf_token %}
<input type="submit" value="Edit Book">
</a>
<ul class="footer">
<li><a href="{% url 'bookshelf:home' %}">Home</a></li>
<li><a href="{% url 'bookshelf:authors' %}">Authors</a></li>
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Author {% endblock %}
{% block content %}
<div class="form">
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit" />
</form>
</div>
<ul class="footer">
<li><a href="{% url 'bookshelf:home' %}">Home</a></li>
<li><a href="{% url 'bookshelf:authors' %}">Authors</a></li>
<li><a href="{% url 'bookshelf:books' %}">Books</a></li>
</ul>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block content %}
<div class="form">
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit" />
</form>
</div>
<ul class="footer">
<li><a href="{% url 'bookshelf:home' %}">Home</a></li>
<li><a href="{% url 'bookshelf:authors' %}">Authors</a></li>
<li><a href="{% url 'bookshelf:books' %}">Books</a></li>
</ul>
{% endblock %}
......@@ -11,11 +11,11 @@ urlpatterns = [
path('books/', BookListView.as_view(), name='books'),
path('books/<int:pk>/details/', BookDetailView.as_view(), name='book-details'),
path('books/add', BooksCreateView.as_view(), name='book-create'),
path('books/<int:pk>', BooksUpdateView.as_view(), name='book-update'),
path('books/<int:pk>/edit/', BooksUpdateView.as_view(), name='book-update'),
path('authors/', AuthorListView.as_view(), name='authors'),
path('authors/<int:pk>/details/', AuthorDetailView.as_view(), name='author-details'),
path('authors/add', AuthorCreateView.as_view(), name='author-create'),
path('authors/<int:pk>', BooksUpdateView.as_view(), name='author-update'),
path('authors/<int:pk>/edit', AuthorUpdateView.as_view(), name='author-update'),
]
app_name = "bookshelf"
......@@ -40,7 +40,7 @@ class AuthorCreateView(CreateView):
class AuthorUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = 'author_details.html'
template_name = 'bookshelf/edit-author.html'
class BooksCreateView(CreateView):
......@@ -51,5 +51,5 @@ class BooksCreateView(CreateView):
class BooksUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'book_details.html'
template_name = 'bookshelf/edit-book.html'
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