Commit 6d39344a authored by Trisha Angel Millena's avatar Trisha Angel Millena

Edited models.py and urls.py, Edited books.html and authors.html

parent 9cb3c5b3
from django.db import models
from django.urls import reverse
# Create your models here.
......@@ -13,7 +15,7 @@ class Author(models.Model):
return self.first_name + ' ' + self.last_name
def get_absolute_url(self):
return reverse('author-detail', kwargs = {'pk': self.pk},)
return reverse("bookshelf:author-details", kwargs = {"pk": self.pk})
class Books(models.Model):
title = models.CharField(max_length = 100)
......@@ -27,4 +29,4 @@ class Books(models.Model):
return self.title
def get_absolute_url(self):
return reverse('book-detail', kwargs = {'pk': self.pk},)
return reverse('bookshelf:book-details', kwargs = {'pk': self.pk})
\ No newline at end of file
......@@ -2,8 +2,13 @@
{% load static %}
{% block title %} {% endblock %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h1>Trisha's Favorite Authors</h1>
<ul>
{% for object in object_list %}
<li style = "list-style-type: circle">
</ul>
{% endblock %}
\ No newline at end of file
......@@ -2,8 +2,20 @@
{% load static %}
{% block title %} {% endblock %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h1>Trisha's Favorite Authors</h1>
<ul>
{% for object in object_list %}
<li>
<a href = '{{ object.get_absolute_url }}'>
{{ object.first_name }}
</a>
</li>
{% endfor %}
</ul>
<a href='/bookshelf/home/'>Home</a>
<a href='/bookshelf/authors/'>Books</a>
{% endblock %}
\ No newline at end of file
......@@ -16,4 +16,7 @@
{% endfor %}
</ul>
<a href='/bookshelf/home/'>Home</a>
<a href='/bookshelf/authors/'>Authors</a>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (
home, BookListView, BookDetailView, AuthorListView, AuthorDetailView
home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView
)
urlpatterns = [
path('home/', home, name = 'home'),
path('books/', BookListView.as_view(), name = 'book-details'),
path('books/<int:pk>/details', BookDetailView.as_view(), name = 'book-details'),
path('books/', BooksListView.as_view(), name = 'books-list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name = 'book-details'),
path('authors/', AuthorListView.as_view(), name = 'author-list'),
path('author/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -9,11 +9,11 @@ from .models import Author, Books
def home(request):
return render(request, 'bookshelf/home.html')
class BookListView(ListView):
class BooksListView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BookDetailView(DetailView):
class BooksDetailView(DetailView):
model = Books
template_name = 'bookshelf/book_details.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