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

Edited views.py

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