Commit 136ab381 authored by MJoshBen's avatar MJoshBen

Implemented all the HTML files for the App while also Updating its URLs and...

Implemented all the HTML files for the App while also Updating its URLs and View Function respectively
parent 7c0950c1
{% extends 'base.html' %}
{% block title %}{{ author }}{% endblock %}
{% block content %}
<h1>{{ author }}</h1>
<h3>{{ author.age }}<br>
{{ author.nationality }}<br>
{{ author.bio }}</h3><br>
<h3> Books by {{ author }} I love:</h3>
<ul>
{% for book in author.books_set.all %}
<li><a href="http://127.0.0.1:8000/{{ book.get_absolute_url }}">{{ book.title }}</a></li>
{% endfor %}
</ul>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/books">Books</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
{% extends 'base.html' %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h1>{{ name }}'s Favorite Authors</h1>
<ul><h3>
{% for author in authors %}
<li><a href="{{ author.get_absolute_url }}">{{ author }}</li>
{% endfor %}
</h3></ul>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/books">Books</a>
{% endblock %}
{% extends 'base.html' %}
{% block title %}{{ book.title }}{% endblock %}
{% block content %}
<h1>{{ book.title }}</h1>
<h3><a href="{{ book.author.get_absolute_url }}">{{ book.author }}</a><br>
{{ book.publisher }}<br>
{{ book.year_published }}<br>
{{ book.ISBN }}<br>
{{ book.blurb }}</h3>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/books">Books</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
{% extends 'base.html' %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h1>{{ name }}'s Favorite Books</h1>
<ul><h3>
{% for book in books %}
<li><a href="{{ book.get_absolute_url }}">{{ book }}</li>
{% endfor %}
</h3></ul>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
{% extends 'base.html' %}
{% block title %}My Favorite Books & Authors{% endblock %}
{% block content %}
<h1> Welcome to {{ name }}'s Database of <br>
Favorite Books and Authors! </h1><br><br>
<h3>I do not read books that often that are from like American<br>
but I am a heavy reader of Japanese books that they call<br>
"Manga's". Every since I was a child my father introduced<br>
to me anime and it has been pretty much a big part of my<br>
life. Whenever I have free time I always try to read <br>
mangas of recent animes that I find interesting to read.<br>
I also try to watch their animated versions when they release </h3><br><br>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/books">Books</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
from django.urls import path
from .views import homepage_view, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView
urlpatterns = [
path('home/', homepage_view, name='home'),
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='authors-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author-details'),
]
app_name = "bookshelf"
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
# Create your views here. # Create your views here.
from .models import Books, Author
def homepage_view(request):
return render(request, 'bookshelf/home.html', {'name': "Josh"})
class BooksListView(ListView):
model = Books
def get(self, request):
return render(request, 'bookshelf/books.html', {'name': "Josh", 'books': self.model.objects.all()})
class BooksDetailView(DetailView):
model = Books
def get(self, request, pk):
return render(request, 'bookshelf/book_details.html', {'book': self.model.objects.get(pk=pk)})
class AuthorListView(ListView):
model = Author
def get(self, request):
return render(request, 'bookshelf/authors.html', {'name': "Josh", 'authors': self.model.objects.all()})
class AuthorDetailView(DetailView):
model = Author
def get(self, request, pk):
return render(request, 'bookshelf/author_details.html', {'author': self.model.objects.get(pk=pk)})
...@@ -14,8 +14,9 @@ Including another URLconf ...@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('', include('bookshelf.urls', namespace="bookshelf")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
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