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

Added Edit Views for Author and Book models

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