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 import django.core.validators
from django.db import migrations, models from django.db import migrations, models
...@@ -25,12 +25,14 @@ class Migration(migrations.Migration): ...@@ -25,12 +25,14 @@ class Migration(migrations.Migration):
], ],
), ),
migrations.CreateModel( migrations.CreateModel(
name='Books', name='Book',
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)), ('title', models.CharField(max_length=100)),
('publisher', 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}$')])), ('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')), ('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 import django.core.validators
from django.db import migrations, models from django.db import migrations, models
...@@ -7,13 +7,13 @@ from django.db import migrations, models ...@@ -7,13 +7,13 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('bookshelf', '0002_auto_20230328_1255'), ('bookshelf', '0002_auto_20230330_0843'),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='book', model_name='book',
name='blurb', name='ISBN',
field=models.CharField(max_length=200, validators=[django.core.validators.MinLengthValidator(100)]), 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.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): class Author(models.Model):
...@@ -13,16 +15,16 @@ class Author(models.Model): ...@@ -13,16 +15,16 @@ class Author(models.Model):
return '{} {}'.format(self.first_name, self.last_name) return '{} {}'.format(self.first_name, self.last_name)
def get_absolute_url(self): 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): class Book(models.Model):
title = models.CharField(max_length=100) 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) publisher = models.CharField(max_length=100)
year_published = models.CharField(max_length=4, validators=[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(r'^\d{1,10}$')]) ISBN = models.CharField(primary_key=True, max_length=13,validators=[MinLengthValidator(13), RegexValidator('^(\d{13})$')])
blurb = models.CharField(max_length=200, validators=[MinLengthValidator(100)]) blurb = models.CharField(max_length=200, validators=[MinLengthValidator(100)])
def __str__(self): def __str__(self):
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}{{object.first_name}}{{object.last_name}}{% endblock %} {% block title %}{{object.first_name}} {{object.last_name}}{% endblock %}
{% block content %} {% block content %}
<h1>{{object.title}}</h1> <h1>{{object.first_name}} {{object.last_name}}</h1>
<ul> <ul>
<li>{{object.age}}</li> Age: {{object.age}}<br>
<li>{{object.nationality}}</li> Nationality: {{object.nationality}}<br>
<li>{{object.bio}}</li> About the Author:<br>
<div class="container">
{{object.bio}}<br>
</div>
</ul> </ul>
<br> <br>
<h2>Books by {{object.first_name}} {{object.last_name}} that I love:</h2> <h2>Books by {{object.first_name}} {{object.last_name}} that I love:</h2>
<ul> <ul>
{% for book in object.books.all %} {% for book in object.books.all %}
<li> <li>
<a href="{{ book.get_absolute_url }}">{{book.title}}</a> <a href="{{book.get_absolute_url}}">{{book.title}}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="container space-evenly"> {% endblock %}
<a href="/home">Home</a> {% block navbar %}
<a href="/books">Books</a> <li><a href="/bookshelf/home">Home</a></li>
<a href="/authors">Authors</a> <li><a href="/bookshelf/books">Books</a></li>
</div> <li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %} {% endblock %}
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
{% block title %}My Favorite Authors{% endblock %} {% block title %}My Favorite Authors{% endblock %}
{% block content %} {% block content %}
<h1 class="text-center">Rach's Favorite Authors:</h1> <h1>Rach's Favorite Authors:</h1>
<br>
<ul> <ul>
{% for object in object_list %} {% for object in object_list %}
<li> <li>
...@@ -14,8 +13,9 @@ ...@@ -14,8 +13,9 @@
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="container space-evenly"> {% endblock %}
<a href="/home">Home</a> {% block navbar %}
<a href="/books">Books</a> <li><a href="/bookshelf/home">Home</a></li>
</div> <li><a href="/bookshelf/books">Books</a></li>
<li><a href="#">Authors</a></li>
{% endblock %} {% endblock %}
...@@ -3,20 +3,18 @@ ...@@ -3,20 +3,18 @@
{% block title %}{{object.title}}{% endblock %} {% block title %}{{object.title}}{% endblock %}
{% block content %} {% block content %}
<h1>{{object.title}}</h1> <h1>{{object.title}} ({{object.year_published}})</h1>
<ul> <ul>
<li> By <a href="{{ object.author.get_absolute_url }}">{{object.author}}</a><br>
<a href="{{ object.author.get_absolute_url }}">{{object.author}}</a> Published by {{object.publisher}}<br>
</li> <br>
<li>{{object.publisher}}</li> <li>ISBN: {{object.ISBN}}</li>
<li>{{object.year_published}}</li>
<li>{{object.ISBN}}</li>
<li>{{object.blurb}}</li> <li>{{object.blurb}}</li>
</ul> </ul>
<br> <br>
<div class="container space-evenly"> {% endblock %}
<a href="/home">Home</a> {% block navbar %}
<a href="/books">Books</a> <li><a href="/bookshelf/home">Home</a></li>
<a href="/authors">Authors</a> <li><a href="/bookshelf/books">Books</a></li>
</div> <li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %} {% endblock %}
...@@ -3,20 +3,19 @@ ...@@ -3,20 +3,19 @@
{% block title %}My Favorite Books{% endblock %} {% block title %}My Favorite Books{% endblock %}
{% block content %} {% block content %}
<h1 class="text-center">Rach's Favorite Books:</h1> <h1>Rach's Favorite Books:</h1>
<br>
<ul> <ul>
{% for object in object_list %} {% for object in object_list %}
<li> <li>
<a href="{{ object.get_absolute_url }}"> <a href="{{object.get_absolute_url}}">
{{ object.title }} {{object.title}}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="container space-evenly"> {% endblock %}
<a href="/home">Home</a> {% block navbar %}
<a href="/authors">Authors</a> <li><a href="/bookshelf/home">Home</a></li>
</div> <li><a href="#">Books</a></li>
<li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %} {% endblock %}
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
{% load static %} {% load static %}
{% block title %}My Favorite Books & Authors{% endblock %} {% block title %}My Favorite Books & Authors{% endblock %}
{% block content %} {% block content %}
<h1 class="text-center">Welcome to Rach's Database of Favorite Books and Authors!</h1> <h1 class="text-center">Welcome to Rach's Database of Favorite Books and Authors!</h1>
<br>
<p class="text-center"> <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. !! Book !! Review !! I do not like reading that much but these are some of the books I would like to gatekeep.
</p> </p>
<br> {% endblock %}
<div class="container space-evenly"> {% block navbar %}
<a href="/books">Books</a> <li><a href="#">Home</a></li>
<a href="/authors">Authors</a> <li><a href="/bookshelf/books">Books</a></li>
</div> <li><a href="/bookshelf/authors">Authors</a></li>
{% endblock %} {% endblock %}
...@@ -18,5 +18,5 @@ from django.urls import path, include ...@@ -18,5 +18,5 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('',include('bookshelf.urls', namespace='bookshelf')), path('bookshelf/',include('bookshelf.urls', namespace='bookshelf')),
] ]
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <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> <title>{% block title %}My amazing site{% endblock %}</title>
{% block styles %}{% endblock %} {% block styles %}{% endblock %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
{% block navbar %}
{% endblock %}
</ul>
</div>
</nav>
</head> </head>
<body> <body>
<div id="content"> <div id="content">
<div class="container">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
</div>
<br><br><br>
{% block scripts %}{% endblock %} {% 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> </body>
</html> </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