templates

parent 703f4c38
...@@ -6,14 +6,14 @@ class BooksInline(admin.TabularInline): ...@@ -6,14 +6,14 @@ class BooksInline(admin.TabularInline):
class AuthorAdmin(admin.ModelAdmin): class AuthorAdmin(admin.ModelAdmin):
model = Author model = Author
list_display = ('first_name', 'last_name', 'age', 'nationality',) list_display = ('first_name', 'last_name', 'age', 'nationality', 'bio')
search_field = ('first_name', 'last_name', 'age', 'nationality',) search_field = ('first_name', 'last_name', 'age', 'nationality', 'bio')
inlines = [BooksInline] inlines = [BooksInline]
class BooksAdmin(admin.ModelAdmin): class BooksAdmin(admin.ModelAdmin):
model = Books model = Books
list_display = ('title', 'author', 'publisher', 'year_published', 'ISBN',) list_display = ('title', 'author', 'publisher', 'year_published', 'ISBN', 'blurb')
search_field = ('title', 'author', 'publisher', 'year_published', 'ISBN',) search_field = ('title', 'author', 'publisher', 'year_published', 'ISBN', 'blurb')
admin.site.register(Author, AuthorAdmin) admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin) admin.site.register(Books, BooksAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-28 13:01
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(blank=True, max_length=50, null=True)),
('last_name', models.CharField(blank=True, max_length=50, null=True)),
('age', models.IntegerField(blank=True, null=True)),
('nationality', models.CharField(blank=True, max_length=50, null=True)),
('bio', models.TextField(blank=True, max_length=700, null=True)),
],
),
migrations.CreateModel(
name='Books',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(blank=True, max_length=50, null=True)),
('publisher', models.CharField(blank=True, max_length=50, null=True)),
('year_published', models.CharField(blank=True, max_length=50, null=True)),
('ISBN', models.IntegerField(blank=True, null=True)),
('blurb', models.TextField(blank=True, null=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
...@@ -13,7 +13,7 @@ class Author(models.Model): ...@@ -13,7 +13,7 @@ class Author(models.Model):
class Books(models.Model): class Books(models.Model):
title = models.CharField(max_length=50, blank=True, null=True) title = models.CharField(max_length=50, blank=True, null=True)
author = models.ForeignKey(Author, on_delete=models.CASCADE) author = models.ForeignKey(Author, on_delete=models.CASCADE)
publisher = models.DateTimeField() publisher = models.CharField(max_length=50, blank=True, null=True)
year_published = models.CharField(max_length=50, blank=True, null=True) year_published = models.CharField(max_length=50, blank=True, null=True)
ISBN = models.IntegerField(blank=True, null=True) ISBN = models.IntegerField(blank=True, null=True)
blurb = models.TextField(blank=True, null=True) blurb = models.TextField(blank=True, null=True)
......
from django.http import HttpResponse from django.shortcuts import render
from django.views import View
def index(request): def index(request):
return HttpResponse("Welcome to neolithic's Music Library!") return render(request, 'home.html', {'nickname': 'Neo'})
No preview for this file type
...@@ -10,6 +10,7 @@ For the full list of settings and their values, see ...@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/ https://docs.djangoproject.com/en/4.1/ref/settings/
""" """
import os
from pathlib import Path from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
...@@ -68,6 +69,8 @@ TEMPLATES = [ ...@@ -68,6 +69,8 @@ TEMPLATES = [
}, },
] ]
SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/'
WSGI_APPLICATION = 'neoballesteros_reading.wsgi.application' WSGI_APPLICATION = 'neoballesteros_reading.wsgi.application'
......
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<title>{% block title %} My amazing site{% endblock %}</title>
{% block styles %}{% endblock %}
</head>
<body>
<div id="content">
{% block content %}Jellatin{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Books & Authors{% endblock %}
{% block content %}
<h1>Welcome to {{nickname}}'s Database of Favorite Books and Authors!</h1>
<p>The books I enjoy range from the genres of self-help, philosophy, psychology, pop fiction, and tragedy with romance. In particular, authors who have a sophisticated way of framing simple things to have a more profound meaning are my go to.</p>
{% endblock %}
\ 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