Commit 5adc7b82 authored by Washington99's avatar Washington99

Bookshelf template and templates change of directory

Creation of the template for the authors and books models. Can now be viewed in localhost/home. Change the directory for the base and home template to be app based instead of project wide as it made file traversal faster.
parent f2fbcbee
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h2>Thris' Database of Favorite Authors</h2>
<div>
{% for object in object_list %}
<p><a href = "">
{{object}}
</a></p>
{% endfor %}
</div>
<a href="/home">Home</a>
<a href="/books">Books</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Books & Authors{% endblock %}
{% block content %}
<h2>Thris' Database of Favorite Books</h2>
<div>
{% for object in object_list %}
<p><a href = "">
{{object}}
</a></p>
{% endfor %}
</div>
<a href="/home">Home</a>
<a href="/authors">Authors</a>
{% endblock %}
\ No newline at end of file
...@@ -17,6 +17,6 @@ ...@@ -17,6 +17,6 @@
type of books. :> type of books. :>
</div> </div>
<a href="">Books</a> <a href="/authors">Authors</a>
<a href="">Authors</a> <a href="/books">Books</a>
{% endblock %} {% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import home_view from .views import home_view, AuthorList, BookList
urlpatterns = [ urlpatterns = [
path('home/', home_view, name='home_view'), path('home/', home_view, name = 'home_view'),
path('authors/', AuthorList.as_view(), name = 'authors'),
path('books/', BookList.as_view(), name = 'books'),
] ]
app_name = "bookshelf" app_name = "bookshelf"
......
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from .models import Author, Books
# Create your views here. # Create your views here.
def home_view(request): def home_view(request):
return render(request, 'home.html') return render(request, 'home.html')
class AuthorList(ListView):
model = Author
template_name = 'bookshelf/authors.html'
class BookList(ListView):
model = Books
template_name = 'bookshelf/books.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