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
...@@ -5,4 +5,8 @@ env/ ...@@ -5,4 +5,8 @@ env/
venv/ venv/
ENV/ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
\ No newline at end of file
#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): ...@@ -13,10 +13,10 @@ class Author(models.Model):
return "{} {}".format(self.first_name, self.last_name) return "{} {}".format(self.first_name, self.last_name)
def get_absolute_url(self): 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) title = models.CharField(max_length=50, blank=True)
author = models.ForeignKey( author = models.ForeignKey(
Author, Author,
......
<head> <head>
<link rel="stylesheet" href="formatt.css">
<title>{% block title %}{% endblock %}</title>
</head> </head>
<body> <body>
<h1>{% block title %}{% endblock %}</h1> <h1>{% block additional %}{% endblock %}</h1>
{% block additional %}{% endblock %}
<div>{% block content %}{% endblock %}</div> <div>{% block content %}{% endblock %}</div>
</body> </body>
\ No newline at end of file
{% 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 @@ ...@@ -2,7 +2,7 @@
{% block title %} My favorite Books and Authors {% endblock %} {% 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 %} {% 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> <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 @@ ...@@ -12,4 +12,3 @@
</div> </div>
{% endblock %} {% endblock %}
# bookshelf/urls.py # bookshelf/urls.py
from django.urls import path from django.urls import path
from .views import (homeView, BooksView, BooksDetails) from .views import (homeView, BooksView, BooksDetail, AuthorView, AuthorDetail)
urlpatterns = [ urlpatterns = [
path('home/', homeView, name='home'), path('home/', homeView, name='home'),
path('books/', BooksView.as_view(), name='books'), path('books/', BooksView.as_view(), name="books"),
path('books/<int:pk>/details/', BooksDetails.as_view(), name='book-details'), 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 # This might be needed, depending on your Django version
......
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from .models import Author, Book
from .models import Author, Books
def homeView(request): def homeView(request):
return render(request, 'home.html') return render(request, 'home.html')
class BooksView(ListView): class BooksView(ListView):
model = Books model = Book
template_name = 'bookshelf/booksView.html' template_name = "bookshelf/books.html"
class BooksDetails(DetailView): class BooksDetail(DetailView):
model = Books model = Book
template_name = 'bookshelf/books_detais.html' template_name = "bookshelf/book_detais.html"
class AuthorView(ListView): class AuthorView(ListView):
model = Author model=Author
template_name = 'bookshelf/author.html' template_name = "bookshelf/authors.html"
class AuthorDetails(DetailView): class AuthorDetail(DetailView):
model = Author model=Author
template_name = 'bookshelf/author_details.html' template_name = "bookshelf/authors_details.html"
\ No newline at end of file
...@@ -14,10 +14,9 @@ Including another URLconf ...@@ -14,10 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path
from django.urls import path, include from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), 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