Commit 3843fa16 authored by Jose Gabriel L. Salas's avatar Jose Gabriel L. Salas

added books and authors edit html pages inide author/book details

parent 824e5edd
......@@ -13,6 +13,7 @@ class Author(models.Model):
return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self):
prime = self.pk
return reverse('bookshelf:authors-detail', kwargs={'pk': self.pk})
class Books(models.Model):
......
......@@ -11,6 +11,11 @@
{{object.bio}}
<br>
<br>
<a href="/bookshelf/authors/{{ object.pk }}/edit">
<button>Edit Author</button>
</a>
<br>
<br>
<h>Books by {{ object }} I love:</h>
<br>
{% for book in books %}
......
......@@ -14,6 +14,12 @@
<br>
{{object.blurb}}
<br>
<br>
<a href="/bookshelf/books/{{ object.pk }}/edit">
<button>Edit Book</button>
</a>
<br>
<br>
<a href="/bookshelf/home/">Home</a>
<a href="/bookshelf/books/">Books</a>
<a href="/bookshelf/authors/">Authors</a>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Books{% endblock %}
{% block content %}
<form action = "" method = "post">
{% csrf_token %}
{{ form.as_p }}
<p><input type="submit" value ="Save Changes"></p>
</form>
{% endblock %}
......@@ -6,6 +6,7 @@ from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from .forms import AddBookForm, BookForm
from django.views.generic.edit import CreateView, UpdateView
from django.urls import reverse
def index(request):
return render(request, 'bookshelf/home.html', {'name': 'Gab'})
......@@ -19,17 +20,17 @@ class AuthorUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
prime = Author.pk
class BookCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class BookUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
template_name = 'bookshelf/edit-books.html'
class BooksListView(ListView):
model = Books
......
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