Commit ff56a4af authored by Stefan Gomez's avatar Stefan Gomez

Created the base template of the project.

parent 8d112ad8
from django.contrib import admin from django.contrib import admin
from.models import Author, Books from.models import Author, Book
class AuthorAdmin(admin.ModelAdmin): class AuthorAdmin(admin.ModelAdmin):
model = Author model = Author
class BooksAdmin(admin.ModelAdmin): class BookAdmin(admin.ModelAdmin):
model = Books model = Book
admin.site.register(Author, AuthorAdmin) admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin) admin.site.register(Book, BookAdmin)
# Generated by Django 4.1.7 on 2023-03-27 10:54
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('age', models.IntegerField()),
('nationality', models.CharField(max_length=20)),
('bio', models.TextField(max_length=700)),
],
),
migrations.CreateModel(
name='Books',
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.IntegerField()),
('ISBN', models.IntegerField()),
('blurb', models.TextField(max_length=200)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-27 11:20
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Books',
new_name='Book',
),
]
# Generated by Django 4.1.7 on 2023-03-27 11:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_rename_books_book'),
]
operations = [
migrations.AlterField(
model_name='book',
name='blurb',
field=models.TextField(),
),
]
...@@ -11,7 +11,7 @@ class Author(models.Model): ...@@ -11,7 +11,7 @@ class Author(models.Model):
def __str__(self): def __str__(self):
return '{}, {}'.format(self.last_name, self.first_name) return '{}, {}'.format(self.last_name, self.first_name)
class Books(models.Model): class Book(models.Model):
title = models.CharField(max_length=100) title = models.CharField(max_length=100)
author = models.ForeignKey( author = models.ForeignKey(
Author, Author,
...@@ -20,7 +20,7 @@ class Books(models.Model): ...@@ -20,7 +20,7 @@ class Books(models.Model):
publisher = models.CharField(max_length=100) publisher = models.CharField(max_length=100)
year_published = models.IntegerField() year_published = models.IntegerField()
ISBN = models.IntegerField() ISBN = models.IntegerField()
blurb = models.TextField(max_length =200) blurb = models.TextField()
def __str__(self): def __str__(self):
return '{}'.format(self.title) return '{}'.format(self.title)
\ No newline at end of file
...@@ -60,7 +60,7 @@ ROOT_URLCONF = 'stefan_gomez_reading.urls' ...@@ -60,7 +60,7 @@ ROOT_URLCONF = 'stefan_gomez_reading.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
......
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<title>{% block title %} {% endblock %}</title>
</head>
<body>
<main>
{% block content %} {% endblock %}
</main>
<footer>
<p>{% block footer %} {% endblock %}</p>
</footer>
</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