Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
javing_reading
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
John Aidan Vincent M. Ng
javing_reading
Commits
aaa111b1
Commit
aaa111b1
authored
Mar 27, 2023
by
Javi Ng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrote template code TODO: navigation bar
parent
ea8ea2ff
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
78 additions
and
6 deletions
+78
-6
.DS_Store
.DS_Store
+0
-0
models.cpython-310.pyc
javing_reading/bookshelf/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
javing_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
javing_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
models.py
javing_reading/bookshelf/models.py
+3
-2
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+21
-0
authors.html
javing_reading/bookshelf/templates/bookshelf/authors.html
+16
-0
book_details.html
...g_reading/bookshelf/templates/bookshelf/book_details.html
+16
-0
books.html
javing_reading/bookshelf/templates/bookshelf/books.html
+16
-0
urls.py
javing_reading/bookshelf/urls.py
+2
-2
views.py
javing_reading/bookshelf/views.py
+4
-2
No files found.
.DS_Store
View file @
aaa111b1
No preview for this file type
javing_reading/bookshelf/__pycache__/models.cpython-310.pyc
View file @
aaa111b1
No preview for this file type
javing_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
aaa111b1
No preview for this file type
javing_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
aaa111b1
No preview for this file type
javing_reading/bookshelf/models.py
View file @
aaa111b1
from
django.db
import
models
from
django.urls
import
reverse
# Create your models here.
class
Author
(
models
.
Model
):
...
...
@@ -19,7 +20,7 @@ class Author (models.Model):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
,
related_name
=
'booklist'
)
publisher
=
models
.
CharField
(
max_length
=
100
)
year_published
=
models
.
IntegerField
(
default
=
1984
)
...
...
@@ -28,4 +29,4 @@ class Book (models.Model):
blurb
=
models
.
TextField
(
max_length
=
200
)
def
get_absolute_url
(
self
):
return
(
reverse
(
'bookdetail'
,
kwargs
=
{
'pk'
:
self
.
pk
}))
return
(
reverse
(
'bookdetail'
,
kwargs
=
{
'pk'
:
self
.
pk
}))
\ No newline at end of file
javing_reading/bookshelf/templates/bookshelf/author_details.html
View file @
aaa111b1
{% extends 'base.html' %}
{% block title %} {{ object }} {% endblock %}
{% block content %}
<h1>
{{ object }}
</h1>
<h2>
{{ object.age }}
</h2>
{{ object.nationalism }}
<br>
{{ object.bio }}
<br>
<br>
Books by {{ object }} I love:
<ul>
{% for book in object.booklist.all %}
<li>
<a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
javing_reading/bookshelf/templates/bookshelf/authors.html
View file @
aaa111b1
{% extends 'base.html' %}
{% block title %} My Favorite Authors {% endblock %}
{% block content %}
<h1>
Javi's Favorite Authors:
</h1>
<ul>
{% for author in author_list %}
<li>
<a
href=
"{{ author.get_absolute_url }}"
>
{{ author }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
javing_reading/bookshelf/templates/bookshelf/book_details.html
View file @
aaa111b1
{% extends 'base.html' %}
{% block title %} {{ object.title }} {% endblock %}
{% block content %}
<h1>
{{ object.title }}
</h1>
<h2>
<a
href =
{{
object
.
author
.
get_absolute_url
}}
>
{{ object.author }}
</a>
</h2>
{{ object.publisher }}
<br>
Published {{ object.year_published}}
<br>
<br>
ISBN {{ object.ISBN }}
<br>
<br>
{{ object.blurb }}
<br>
{% endblock %}
\ No newline at end of file
javing_reading/bookshelf/templates/bookshelf/books.html
View file @
aaa111b1
{% extends 'base.html' %}
{% block title %} My Favorite Books {% endblock %}
{% block content %}
<h1>
Javi's Favorite Books:
</h1>
<ul>
{% for book in book_list %}
<li>
<a
href=
"{{ book.get_absolute_url }}"
>
{{book.title}}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
javing_reading/bookshelf/urls.py
View file @
aaa111b1
...
...
@@ -5,6 +5,6 @@ urlpatterns = [
path
(
'home/'
,
views
.
HomeView
,
name
=
"home"
),
path
(
'books/'
,
views
.
BookListView
.
as_view
(),
name
=
"booklist"
),
path
(
'books/<int:pk>/details'
,
views
.
BookDetailView
.
as_view
(),
name
=
"bookdetail"
),
path
(
'authors/'
,
views
.
Book
ListView
.
as_view
(),
name
=
"authorlist"
),
path
(
'authors/<int:pk>/details'
,
views
.
Book
DetailView
.
as_view
(),
name
=
"authordetail"
),
path
(
'authors/'
,
views
.
Author
ListView
.
as_view
(),
name
=
"authorlist"
),
path
(
'authors/<int:pk>/details'
,
views
.
Author
DetailView
.
as_view
(),
name
=
"authordetail"
),
]
\ No newline at end of file
javing_reading/bookshelf/views.py
View file @
aaa111b1
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
.models
import
Author
,
Book
from
datetime
import
date
from
django.views
import
View
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
...
...
@@ -11,13 +9,17 @@ def HomeView(request):
return
render
(
request
,
"bookshelf/home.html"
)
class
BookListView
(
ListView
):
template_name
=
'bookshelf/books.html'
model
=
Book
class
BookDetailView
(
DetailView
):
template_name
=
'bookshelf/book_details.html'
model
=
Book
class
AuthorListView
(
ListView
):
template_name
=
'bookshelf/authors.html'
model
=
Author
class
AuthorDetailView
(
DetailView
):
template_name
=
'bookshelf/author_details.html'
model
=
Author
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment