Commit e062a8d5 authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

attempted to merge but failed. dbsqlite's fault

parents 28f58b1c 84482763
......@@ -6,3 +6,7 @@ venv/
ENV/
env.bak/
venv.bak/
#pycache
__pycache__
.pyc
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-29 04:00
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_alter_book_year_published'),
]
operations = [
migrations.AlterField(
model_name='book',
name='year_published',
field=models.DateField(default=datetime.datetime(2023, 3, 29, 12, 0, 26, 639804)),
),
]
......@@ -13,10 +13,10 @@ class Author(models.Model):
return "{} {}".format(self.first_name, self.last_name)
def get_absolute_url(self):
return reverse()
return self.pk
class Books(models.Model):
class Book(models.Model):
title = models.CharField(max_length=50, blank=True)
author = models.ForeignKey(
Author,
......
<head>
<link rel="stylesheet" href="formatt.css">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<h1>{% block title %}{% endblock %}</h1>
{% block additional %}{% endblock %}
<h1>{% block additional %}{% endblock %}</h1>
<div>{% block content %}{% endblock %}</div>
</body>
{% extends 'base.html' %}
{% block title %} My favorite authors {% endblock %}
{% block additional %} Neptune's favorite authors {% endblock %}
{% block content %}
<ul>
{% for author in object_list %}
<li><a href="{{author.get_absolute_url}}/details/"> {{ author.first_name }}{{ author.last_name }}
{% endfor %}
</ul>
<div>
<a href="/home">Home</a>
<a href="/books">Books</a>
</div>
{% endblock %}
{% extends 'base.html' %}
{% block title %} {{object.first_name}} {{object.last_name}} {% endblock %}
{% block additional %} {{object.first_name}} {{object.last_name}} {% endblock %}
{% block content%}
<ul>
<li> {{object.age}}
<li> {{object.nationality}}
<li> {{object.bio}}
</ul>
<div>
<p> Books by {{object.first_name}} {{object.last_name}} I love: </p>
<ul>
{% for aBook in object.book_set.all %}
<li> <a href="/books/{{aBook.get_absolute_url}}/details/"> {{aBook.title}} </a></li>
{% endfor %}
</ul>
<div>
<a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a>\
</div>
</div>
{% endblock %}
{% extends 'base.html' %}
{% block title %} {{ object.title }} {% endblock %}
{% block additional %} {{ object.title }} {% endblock %}
{% block content %}
<ul>
<li> {{ object.author }} </li>
<li> {{ object.publisher}} </li>
<li> {{ object.year_published}} </li>
<li> {{ object.ISBN}} </li>
<li> {{ object.blurb}} </li>
</ul>
<div>
<a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a>
{% endblock %}
{% extends 'base.html' %}
{% block title%} My favorite books {% endblock %}
{% block additional %} Neptune's favorite books {% endblock %}
{% block content %}
<ul>
{% for obj in object_list %}
<li><a href="{{obj.get_absolute_url}}/details/">{{ obj.title }}</a></li>
{% endfor %}
</ul>
<div>
<a href="/home">Home</a>
<a href="/authors">Authors</a>
</div>
{% endblock %}
\ No newline at end of file
div.uh{
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
{% block title %} My favorite Books and Authors {% endblock %}
{% block additional %} <h3> Welcome to Neptune's database of favorite books and authors</h3> {% endblock %}
{% block additional %} <h1> Welcome to Neptune's database of favorite books and authors</h1> {% endblock %}
{% block content %}
<p>My taste in books are very random and usually done in the spur of the moment. I cannot commit to a series. </p>
......@@ -12,4 +12,3 @@
</div>
{% endblock %}
# bookshelf/urls.py
from django.urls import path
from .views import (homeView, BooksView, BooksDetails)
from .views import (homeView, BooksView, BooksDetail, AuthorView, AuthorDetail)
urlpatterns = [
path('home/', homeView, name='home'),
path('books/', BooksView.as_view(), name='books'),
path('books/<int:pk>/details/', BooksDetails.as_view(), name='book-details'),
path('books/', BooksView.as_view(), name="books"),
path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"),
path('authors/', AuthorView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"),
]
# This might be needed, depending on your Django version
......
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from .models import Author, Books
from .models import Author, Book
def homeView(request):
return render(request, 'home.html')
class BooksView(ListView):
model = Books
template_name = 'bookshelf/booksView.html'
model = Book
template_name = "bookshelf/books.html"
class BooksDetails(DetailView):
model = Books
template_name = 'bookshelf/books_detais.html'
class BooksDetail(DetailView):
model = Book
template_name = "bookshelf/book_detais.html"
class AuthorView(ListView):
model = Author
template_name = 'bookshelf/author.html'
model=Author
template_name = "bookshelf/authors.html"
class AuthorDetails(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
\ No newline at end of file
class AuthorDetail(DetailView):
model=Author
template_name = "bookshelf/authors_details.html"
......@@ -14,10 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('' , include('bookshelf.urls', namespace='bookshelf'))
path('',include('bookshelf.urls', namespace='bookshelf'))
]
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