Books Details and Authors details have been added

parent ff663f4b
# Generated by Django 3.2 on 2023-03-29 15:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='books',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author'),
),
]
......@@ -19,7 +19,7 @@ class Books(models.Model):
title = models.CharField(max_length=1000)
author = models.ForeignKey(
Author,
on_delete=models.PROTECT
on_delete=models.CASCADE
)
publisher = models.CharField(max_length=1000)
year_published = models.IntegerField()
......
......@@ -11,4 +11,5 @@
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
<p><a href="http://127.0.0.1:8000/bookshelf/home">Home</a> <a href="http://127.0.0.1:8000/bookshelf/books">Books</a> </p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }}{% endblock %}
{% block title %} {{ author.first_name }}{% endblock %}
{% block content %}
<h1>{{ object.first_name }} {{object.last_name}}</h1>
<h1>{{ author.first_name }} {{author.last_name}}</h1>
<ul>
<li>{{ object.age }}</li>
<li>{{ object.nationality }}</li>
<li>{{ object.bio }}</li>
<li>{{ author.age }}</li>
<li>{{ author.nationality }}</li>
<li>{{ author.bio }}</li>
</ul>
<p>
<a href="http://127.0.0.1:8000/bookshelf/home">Home</a>
<a href="http://127.0.0.1:8000/bookshelf/books">Books</a>
<a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a>
</p>
{% endblock %}
\ No newline at end of file
......@@ -5,10 +5,15 @@
{% block content %}
<h1>{{ object.title }}</h1>
<ul>
<li>{{ object.author }}</li>
<li>{{ object.publisher }}</li>
<li>{{ object.year_published }}</li>
<li>{{ object.ISBN }}</li>
<li>{{ object.blurb }}</li>
<li>Author: <a href="{{ object.author.get_absolute_url }}""> {{ object.author }}</a></li>
<li>Publisher: {{ object.publisher }}</li>
<li>Year Published: {{ object.year_published }}</li>
<li>ISBN: {{ object.ISBN }}</li>
<li>Blurb: {{ object.blurb }}</li>
</ul>
<p>
<a href="http://127.0.0.1:8000/bookshelf/home">Home</a>
<a href="http://127.0.0.1:8000/bookshelf/books">Books</a>
<a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a>
</p>
{% endblock %}
\ No newline at end of file
......@@ -11,4 +11,5 @@
</li>
{% endfor %}
</ul>
<p><a href="http://127.0.0.1:8000/bookshelf/home">Home</a> <a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a> </p>
{% endblock %}
\ No newline at end of file
......@@ -10,5 +10,5 @@
<br>that appeals to me.
</p>
<br>
<a href="http://127.0.0.1:8000/bookshelf/books">Books</a>
<p><a href="http://127.0.0.1:8000/bookshelf/books">Books</a> <a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a> </p>
{% endblock %}
\ No newline at end of file
......@@ -17,7 +17,8 @@ class AuthorsListView(ListView):
})
class AuthorsDetailView(DetailView):
models = Author
model = Author
template_name = 'bookshelf/authors_details.html'
class BooksListView(ListView):
def get(self, request):
......@@ -27,4 +28,6 @@ class BooksListView(ListView):
})
class BooksDetailView(DetailView):
models = Books
\ No newline at end of file
model = Books
template_name = 'bookshelf/book_details.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