Commit 9fe488f7 authored by Gabriel Limbaga's avatar Gabriel Limbaga

populated data

parent 315e21cd
from django.contrib import admin from django.contrib import admin
from .models import Author, Books
# Register your models here. # Register your models here.
class AuthorAdmin(admin.ModelAdmin):
model = Author
list_display = ('first_name', 'last_name', 'age', 'nationality', 'bio')
search_fields = ('first_name', 'last_name', 'bio')
list_filter = ('age', 'nationality')
class BooksAdmin(admin.ModelAdmin):
model = Books
list_display = ('title', 'author', 'publisher', 'year_published', 'ISBN', 'blurb')
search_fields = ('title', 'author', 'publisher', 'ISBN', 'blurb')
list_filter = ('author', 'publisher', 'year_published')
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
# Generated by Django 3.2 on 2023-03-28 11:56
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=50)),
('last_name', models.CharField(max_length=50)),
('age', models.IntegerField(default=0)),
('nationality', models.CharField(max_length=50)),
('bio', models.CharField(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=50)),
('publisher', models.CharField(max_length=50)),
('year_published', models.IntegerField(default=0)),
('ISBN', models.IntegerField(default=0)),
('blurb', models.CharField(max_length=200)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
# Generated by Django 3.2 on 2023-03-28 12:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='books',
name='blurb',
field=models.TextField(blank=True),
),
]
# Generated by Django 3.2 on 2023-03-28 12:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_alter_books_blurb'),
]
operations = [
migrations.AlterField(
model_name='author',
name='bio',
field=models.TextField(blank=True),
),
]
...@@ -7,10 +7,10 @@ class Author(models.Model): ...@@ -7,10 +7,10 @@ class Author(models.Model):
last_name = models.CharField(max_length = 50) last_name = models.CharField(max_length = 50)
age = models.IntegerField(default = 0) age = models.IntegerField(default = 0)
nationality = models.CharField(max_length = 50) nationality = models.CharField(max_length = 50)
bio = models.CharField(max_length = 700) bio = models.TextField(blank=True)
def __str__(self): def __str__(self):
return self.first_name return str(self.first_name + ' ' + self.last_name)
class Books(models.Model): class Books(models.Model):
title = models.CharField(max_length = 50) title = models.CharField(max_length = 50)
...@@ -18,7 +18,7 @@ class Books(models.Model): ...@@ -18,7 +18,7 @@ class Books(models.Model):
publisher = models.CharField(max_length = 50) publisher = models.CharField(max_length = 50)
year_published = models.IntegerField(default = 0) year_published = models.IntegerField(default = 0)
ISBN = models.IntegerField(default = 0) ISBN = models.IntegerField(default = 0)
blurb = models.CharField(max_length = 200) blurb = models.TextField(blank=True)
def __str__(self): def __str__(self):
return self.title return self.title
\ No newline at end of file
<!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 %}{% endblock %}
</div>
{% 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