Commit 4b38a08b authored by rachbit's avatar rachbit

updated base.html and templates w CSS via bootstrap

parent 5d7303e0
# Generated by Django 3.2 on 2023-03-28 12:41
# Generated by Django 3.2 on 2023-03-30 08:41
import django.core.validators
from django.db import migrations, models
......@@ -25,12 +25,14 @@ class Migration(migrations.Migration):
],
),
migrations.CreateModel(
name='Books',
name='Book',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('publisher', models.CharField(max_length=100)),
('year_published', models.CharField(max_length=4, validators=[django.core.validators.RegexValidator('^\\d{1,10}$')])),
('ISBN', models.CharField(max_length=13, primary_key=True, serialize=False, validators=[django.core.validators.MinLengthValidator(13), django.core.validators.RegexValidator('^\\d{1,10}$')])),
('ISBN', models.CharField(max_length=13, validators=[django.core.validators.MinLengthValidator(13)])),
('blurb', models.CharField(max_length=200, validators=[django.core.validators.MinLengthValidator(100)])),
('author', models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
......
# Generated by Django 3.2 on 2023-03-28 12:55
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Book',
fields=[
('title', models.CharField(max_length=100)),
('publisher', models.CharField(max_length=100)),
('year_published', models.CharField(max_length=4, validators=[django.core.validators.RegexValidator('^\\d{1,10}$')])),
('ISBN', models.CharField(max_length=13, primary_key=True, serialize=False, validators=[django.core.validators.MinLengthValidator(13), django.core.validators.RegexValidator('^\\d{1,10}$')])),
('blurb', models.CharField(max_length=200)),
('author', models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
migrations.DeleteModel(
name='Books',
),
]
# Generated by Django 3.2 on 2023-03-30 08:43
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='book',
name='id',
),
migrations.AlterField(
model_name='book',
name='ISBN',
field=models.CharField(max_length=13, primary_key=True, serialize=False, validators=[django.core.validators.MinLengthValidator(13), django.core.validators.RegexValidator('^\\d{1,10}$')]),
),
]
# Generated by Django 3.2 on 2023-03-28 13:00
# Generated by Django 3.2 on 2023-03-30 08:47
import django.core.validators
from django.db import migrations, models
......@@ -7,13 +7,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_auto_20230328_1255'),
('bookshelf', '0002_auto_20230330_0843'),
]
operations = [
migrations.AlterField(
model_name='book',
name='blurb',
field=models.CharField(max_length=200, validators=[django.core.validators.MinLengthValidator(100)]),
name='ISBN',
field=models.CharField(max_length=13, primary_key=True, serialize=False, validators=[django.core.validators.RegexValidator('^\\d{1,10}$')]),
),
]
# Generated by Django 3.2 on 2023-03-30 13:56
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0003_alter_book_isbn'),
]
operations = [
migrations.AlterField(
model_name='book',
name='ISBN',
field=models.CharField(max_length=13, primary_key=True, serialize=False, validators=[django.core.validators.MinLengthValidator(13), django.core.validators.RegexValidator('^(\\d{13})$')]),
),
migrations.AlterField(
model_name='book',
name='author',
field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, related_name='books', to='bookshelf.author'),
),
migrations.AlterField(
model_name='book',
name='year_published',
field=models.PositiveIntegerField(validators=[django.core.validators.MaxValueValidator(2023)]),
),
]
from django.db import models
from django.core.validators import MinLengthValidator, RegexValidator
from django.core.validators import MinLengthValidator, RegexValidator, MaxValueValidator
from django.urls import reverse
from datetime import date
class Author(models.Model):
......@@ -13,16 +15,16 @@ class Author(models.Model):
return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self):
return reverse("bookshelf:author_details",kwargs={'pk':self.pk})
return reverse('bookshelf:author_details', kwargs={'pk':self.pk})
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ForeignKey(Author,on_delete=models.CASCADE,default="")
author = models.ForeignKey(Author,on_delete=models.CASCADE,related_name="books",default="")
publisher = models.CharField(max_length=100)
year_published = models.CharField(max_length=4, validators=[RegexValidator(r'^\d{1,10}$')])
ISBN = models.CharField(primary_key=True, max_length=13,validators=[MinLengthValidator(13), RegexValidator(r'^\d{1,10}$')])
year_published = models.PositiveIntegerField(validators=[MaxValueValidator(date.today().year)])
ISBN = models.CharField(primary_key=True, max_length=13,validators=[MinLengthValidator(13), RegexValidator('^(\d{13})$')])
blurb = models.CharField(max_length=200, validators=[MinLengthValidator(100)])
def __str__(self):
......
{% extends 'base.html' %}
{% load static %}
{% block title %}{{object.first_name}}{{object.last_name}}{% endblock %}
{% block title %}{{object.first_name}} {{object.last_name}}{% endblock %}
{% block content %}
<h1>{{object.title}}</h1>
<h1>{{object.first_name}} {{object.last_name}}</h1>
<ul>
<li>{{object.age}}</li>
<li>{{object.nationality}}</li>
<li>{{object.bio}}</li>
Age: {{object.age}}<br>
Nationality: {{object.nationality}}<br>
About the Author:<br>
<div class="container">
{{object.bio}}<br>
</div>
</ul>
<br>
<h2>Books by {{object.first_name}} {{object.last_name}} that I love:</h2>
<ul>
{% for book in object.books.all %}
<li>
<a href="{{ book.get_absolute_url }}">{{book.title}}</a>
<a href="{{book.get_absolute_url}}">{{book.title}}</a>
</li>
{% endfor %}
</ul>
<div class="container space-evenly">
<a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a>
</div>
{% endblock %}
{% block navbar %}
<li><a href="/bookshelf/home">Home</a></li>
<li><a href="/bookshelf/books">Books</a></li>
<li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %}
......@@ -3,8 +3,7 @@
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h1 class="text-center">Rach's Favorite Authors:</h1>
<br>
<h1>Rach's Favorite Authors:</h1>
<ul>
{% for object in object_list %}
<li>
......@@ -14,8 +13,9 @@
</li>
{% endfor %}
</ul>
<div class="container space-evenly">
<a href="/home">Home</a>
<a href="/books">Books</a>
</div>
{% endblock %}
{% block navbar %}
<li><a href="/bookshelf/home">Home</a></li>
<li><a href="/bookshelf/books">Books</a></li>
<li><a href="#">Authors</a></li>
{% endblock %}
......@@ -3,20 +3,18 @@
{% block title %}{{object.title}}{% endblock %}
{% block content %}
<h1>{{object.title}}</h1>
<ul>
<li>
<a href="{{ object.author.get_absolute_url }}">{{object.author}}</a>
</li>
<li>{{object.publisher}}</li>
<li>{{object.year_published}}</li>
<li>{{object.ISBN}}</li>
<h1>{{object.title}} ({{object.year_published}})</h1>
<ul>
By <a href="{{ object.author.get_absolute_url }}">{{object.author}}</a><br>
Published by {{object.publisher}}<br>
<br>
<li>ISBN: {{object.ISBN}}</li>
<li>{{object.blurb}}</li>
</ul>
</ul>
<br>
<div class="container space-evenly">
<a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a>
</div>
{% endblock %}
{% block navbar %}
<li><a href="/bookshelf/home">Home</a></li>
<li><a href="/bookshelf/books">Books</a></li>
<li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %}
......@@ -3,20 +3,19 @@
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h1 class="text-center">Rach's Favorite Books:</h1>
<br>
<h1>Rach's Favorite Books:</h1>
<ul>
{% for object in object_list %}
<li>
<a href="{{ object.get_absolute_url }}">
{{ object.title }}
<a href="{{object.get_absolute_url}}">
{{object.title}}
</a>
</li>
{% endfor %}
</ul>
<div class="container space-evenly">
<a href="/home">Home</a>
<a href="/authors">Authors</a>
</div>
{% endblock %}
{% block navbar %}
<li><a href="/bookshelf/home">Home</a></li>
<li><a href="#">Books</a></li>
<li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %}
......@@ -2,15 +2,15 @@
{% load static %}
{% block title %}My Favorite Books & Authors{% endblock %}
{% block content %}
<h1 class="text-center">Welcome to Rach's Database of Favorite Books and Authors!</h1>
<br>
<p class="text-center">
!! Book !! Review !! I do not like reading that much but these are some of the books I would like to gatekeep.
</p>
<br>
<div class="container space-evenly">
<a href="/books">Books</a>
<a href="/authors">Authors</a>
</div>
{% endblock %}
{% block navbar %}
<li><a href="#">Home</a></li>
<li><a href="/bookshelf/books">Books</a></li>
<li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %}
......@@ -18,5 +18,5 @@ from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('bookshelf.urls', namespace='bookshelf')),
path('bookshelf/',include('bookshelf.urls', namespace='bookshelf')),
]
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<title>{% block title %}My amazing site{% endblock %}</title>
{% block styles %}{% endblock %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
{% block navbar %}
{% endblock %}
</ul>
</div>
</nav>
</head>
<body>
<div id="content">
<div class="container">
{% block content %}{% endblock %}
</div>
</div>
<br><br><br>
{% block scripts %}{% endblock %}
<div class="container">
<p class="text-centered">
<img src="https://media.tenor.com/l1pItZnKEsoAAAAM/funny-as-hell.gif" alt="honkhonk">
where is he going
</p>
</div>
</body>
</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