Commit 9cb3c5b3 authored by Trisha Angel Millena's avatar Trisha Angel Millena

Edited views.py

parent ab5ed2a1
......@@ -2,8 +2,18 @@
{% load static %}
{% block title %}{% endblock %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h1>Trisha's Favorite Books</h1>
<ul>
{% for object in object_list %}
<li>
<a href = '{{ object.get_absolute_url }}'>
{{ object.title }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import (
index, BookListView, BookDetailView, AuthorListView, AuthorDetailView
home, BookListView, BookDetailView, AuthorListView, AuthorDetailView
)
urlpatterns = [
path('home/', views.home, name = 'home'),
path('books/', views.BooksListView.as_view(), name = 'book-details'),
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('authors/', AuthorListView.as_view(), name = 'author-list'),
path('author/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'),
......
from django.shortcuts import render
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detatil import DetailView
from django.views.generic.detail import DetailView
from .models import Author, Books
# Create your views here.
......@@ -11,12 +11,16 @@ def home(request):
class BookListView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BookDetailView(DetailView):
model = Books
template_name = 'bookshelf/book_details.html'
class AuthorListView(ListView):
model = Author
template_name = 'bookshelf/authors.html'
class AuthorDetailView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
\ No newline at end of file
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