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): ...@@ -13,6 +13,7 @@ class Author(models.Model):
return '{} {}'.format(self.first_name, self.last_name) return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self): def get_absolute_url(self):
prime = self.pk
return reverse('bookshelf:authors-detail', kwargs={'pk': self.pk}) return reverse('bookshelf:authors-detail', kwargs={'pk': self.pk})
class Books(models.Model): class Books(models.Model):
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
{{object.bio}} {{object.bio}}
<br> <br>
<br> <br>
<a href="/bookshelf/authors/{{ object.pk }}/edit">
<button>Edit Author</button>
</a>
<br>
<br>
<h>Books by {{ object }} I love:</h> <h>Books by {{ object }} I love:</h>
<br> <br>
{% for book in books %} {% for book in books %}
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
<br> <br>
{{object.blurb}} {{object.blurb}}
<br> <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/home/">Home</a>
<a href="/bookshelf/books/">Books</a> <a href="/bookshelf/books/">Books</a>
<a href="/bookshelf/authors/">Authors</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 ...@@ -6,6 +6,7 @@ from django.views.generic.detail import DetailView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from .forms import AddBookForm, BookForm from .forms import AddBookForm, BookForm
from django.views.generic.edit import CreateView, UpdateView from django.views.generic.edit import CreateView, UpdateView
from django.urls import reverse
def index(request): def index(request):
return render(request, 'bookshelf/home.html', {'name': 'Gab'}) return render(request, 'bookshelf/home.html', {'name': 'Gab'})
...@@ -19,17 +20,17 @@ class AuthorUpdateView(UpdateView): ...@@ -19,17 +20,17 @@ class AuthorUpdateView(UpdateView):
model = Author model = Author
fields = '__all__' fields = '__all__'
template_name = 'bookshelf/edit-author.html' template_name = 'bookshelf/edit-author.html'
prime = Author.pk
class BookCreateView(CreateView): class BookCreateView(CreateView):
model = Books model = Books
fields = '__all__' fields = '__all__'
template_name = 'bookshelf/add-book.html' template_name = 'bookshelf/add-book.html'
class BookUpdateView(UpdateView): class BookUpdateView(UpdateView):
model = Books model = Books
fields = '__all__' fields = '__all__'
template_name = 'bookshelf/edit-book.html' template_name = 'bookshelf/edit-books.html'
class BooksListView(ListView): class BooksListView(ListView):
model = Books 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