Commit ebebefef authored by Albert Gagalac's avatar Albert Gagalac

Implemented working hyperlinks + finished all pages

parent 32d56472
......@@ -15,11 +15,11 @@ class Author(models.Model):
return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self):
return reverse('author', kwargs={'pk' : self.pk})
return reverse('bookshelf:author-detail', kwargs={'pk' : self.pk})
class Book(models.Model):
title = models.CharField(default="", max_length=100)
author = models.ForeignKey(Author, on_delete=models.CASCADE)
author = models.ForeignKey(Author, on_delete=models.CASCADE, unique=True)
publisher = models.CharField(default="", max_length=100)
ISBN = models.PositiveIntegerField(validators=
[RegexValidator(r'^[0-9]*$',
......@@ -31,4 +31,7 @@ class Book(models.Model):
return '{}'.format(self.title)
def get_absolute_url(self):
return reverse('author', kwargs={'pk' : self.pk})
return reverse('bookshelf:books-detail', kwargs={'pk' : self.pk})
def get_home_url(self):
return reverse('bookshelf:books-list')
<p>{{"Widget's Assignments Page"}}<br><br></p>
{% for data in author %}
<p>
first_name: {{data.first_name}}<br>
last_name: {{data.last_name}}<br>
<br>
</p>
{% endfor %}
{% extends 'base.html' %}
{% load static %}
{% block css %} {% endblock %}
{% block title %}{{object}}{% endblock %}
{% block heading %}{{object}}{% endblock %}
{% block content %}
<ul>
<h3>Age:</h3> {{object.age}}<br>
<h3>Nationality:</h3> {{object.nationality}}<br>
<h3>Bio:</h3> {{object.bio}}
<br><br><br><a href="/home/ ">Home</a> | <a href="/books/ ">Books</a> | <a href="/author/ ">Authors</a>
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block css %}
h1 {
text-align: center;
padding-top: 175px;
font-family: "Comic Sans MS", cursive;
}
ul {
text-align: center;
font-family: "Arial", cursive;
}
{% endblock %}
{% block title %}My Favorite Authors{% endblock %}
{% block heading %}Burt's Favorite Authors{% endblock %}
{% block content %}
<ul>
{% for object in object_list %}
<a href="{{ object.get_absolute_url }}">
{{ object }}
</a> <br>
{% endfor %}<br>
<a href="/home/ ">Home</a> | <a href="/books/ ">Books</a> | <a href="/author/ ">Authors</a>
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block css %}
h1 {
text-align: center;
padding-top: 175px;
font-family: "Comic Sans MS", cursive;
}
p {
text-align: center;
font-family: "Arial", cursive;
}
{% endblock %}
{% block title %}{{object}}{% endblock %}
{% block heading %}{{object}}{% endblock %}
{% block content %}
<ul>
<h3>Author:</h3> {{object.author}}<br>
<h3>Publisher:</h3> {{object.publisher}}<br>
<h3>ISBN:</h3> {{object.ISBN}}<br>
<h3>Blurb:</h3> {{object.blurb}}
<br><br><br><a href="/home/ ">Home</a> | <a href="/books/ ">Books</a> | <a href="/author/ ">Authors</a>
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block css %}
h1 {
text-align: center;
padding-top: 175px;
font-family: "Comic Sans MS", cursive;
}
ul {
text-align: center;
font-family: "Arial", cursive;
}
{% endblock %}
{% block title %}My Favorite Books{% endblock %}
{% block heading %}Burt's Favorite Books{% endblock %}
{% block content %}
<ul>
{% for object in object_list %}
<a href="{{ object.get_absolute_url }}">{{object.title}}</a><br>
{% endfor %} <br><br>
<a href="/home/ ">Home</a> | <a href="/author/">Authors</a>
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block heading %}{% endblock %}
{% block content %}
<h1>Hello World. This is the content</h1>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% comment %} {% block %} {% endblock %} {% endcomment %}
{% comment %} {% block css %}
<style>
h1 {
text-align: center;
padding-top: 175px;
}
p {
text-align: center;
}
</style>
{% endblock %} {% endcomment %}
{% block css %}
h1 {
text-align: center;
padding-top: 175px;
font-family: "Comic Sans MS", cursive;
}
p {
text-align: center;
font-family: "Arial", cursive;
}
{% endblock %}
{% block title %} My Favorite Books and Authors {% endblock %}
{% block heading %} Welcome to <br>Burt's Database <br>of Favorite Books and Authors {% endblock %}
{% block content %} In the past I used to be an avid reader of <br>
Sci-Fi and Mythology type novels. In more recent times,<br>
I have come to love more manga that deal with <br>
down-to-earth and realistic themes. <br> <br>
tl;dr: I now weeb <br> <br> <br>
Books | Authors
<a href="/books/ ">Books</a> | <a href="/author/">Authors</a>
{% endblock %}
{% block list %} {% endblock %}
\ No newline at end of file
from django.urls import path
from .views import author, BookPageView, home
from .views import (
AuthorDetailView, BookDetailView,
home, BookListView, AuthorListView
)
urlpatterns = [
path('', home, name='home'),
path("author/", author, name="author"),
path("books/", BookPageView.as_view(), name="books"),
path('home/', home, name='home'),
path("author/", AuthorListView.as_view(), name="author-list"),
path("books/", BookListView.as_view(), name="books-list"),
path("books/<int:pk>/details", BookDetailView.as_view(), name="books-detail"),
path("author/<int:pk>/details", AuthorDetailView.as_view(), name="author-detail"),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -5,17 +5,19 @@ from django.views.generic.detail import DetailView
from .models import Author, Book
# Create your views here.
def home(request):
return render(request, 'bookshelf/home.html')
def author(request):
author = Author.objects.all()
return render(request, 'bookshelf/author.html', {'author' : author})
class BookDetailView(DetailView):
model = Book
class AuthorDetailView(DetailView):
model = Author
class BookListView(ListView):
model = Book
class BookPageView(View):
def get(self, request):
books = Book.objects.order_by('title')
return render(request, 'bookshelf/books.html', {'books' : books})
class AuthorListView(ListView):
model = Author
......@@ -2,25 +2,19 @@
<html lang="en">
<head>
<style>
h1 {
text-align: center;
padding-top: 175px;
}
p {
text-align: center;
}
</style>
<style>
{% block css %}
body {background: rgba(255, 207, 51, 0.938);}
{% endblock %}
</style>
<link rel="stylesheet" href="style.css">
<title>{% block title %}Burt's Book Bemporium{% endblock %}</title>
{% block styles %}{% endblock %}
</head>
<body>
<h1>{% block heading %} {% endblock %}</h1>
<h1>{% block heading %}{% endblock %}</h1>
<div id="content">
<p>{% block content %}{% endblock %}</p>
</div>
{% block list %}{% endblock %}
{% block scripts %}{% endblock %}
</body>
</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