Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
albertgagalac_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
Albert Gagalac
albertgagalac_reading
Commits
c1006fc4
Commit
c1006fc4
authored
Mar 30, 2023
by
Albert Gagalac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'books by author' in books-details
parent
4cf4b889
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
11 deletions
+22
-11
models.cpython-310.pyc
...alac_reading/bookshelf/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
...agalac_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...galac_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
models.py
...gagalac_reading/albertgagalac_reading/bookshelf/models.py
+1
-4
author_detail.html
..._reading/bookshelf/templates/bookshelf/author_detail.html
+12
-3
book_list.html
...alac_reading/bookshelf/templates/bookshelf/book_list.html
+4
-3
urls.py
...rtgagalac_reading/albertgagalac_reading/bookshelf/urls.py
+0
-1
views.py
...tgagalac_reading/albertgagalac_reading/bookshelf/views.py
+5
-0
No files found.
albertgagalac_reading/albertgagalac_reading/bookshelf/__pycache__/models.cpython-310.pyc
View file @
c1006fc4
No preview for this file type
albertgagalac_reading/albertgagalac_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
c1006fc4
No preview for this file type
albertgagalac_reading/albertgagalac_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
c1006fc4
No preview for this file type
albertgagalac_reading/albertgagalac_reading/bookshelf/models.py
View file @
c1006fc4
...
@@ -19,7 +19,7 @@ class Author(models.Model):
...
@@ -19,7 +19,7 @@ class Author(models.Model):
class
Book
(
models
.
Model
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
default
=
""
,
max_length
=
100
)
title
=
models
.
CharField
(
default
=
""
,
max_length
=
100
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
,
unique
=
True
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
default
=
""
,
max_length
=
100
)
publisher
=
models
.
CharField
(
default
=
""
,
max_length
=
100
)
ISBN
=
models
.
PositiveIntegerField
(
validators
=
ISBN
=
models
.
PositiveIntegerField
(
validators
=
[
RegexValidator
(
r'^[0-9]*$'
,
[
RegexValidator
(
r'^[0-9]*$'
,
...
@@ -32,6 +32,3 @@ class Book(models.Model):
...
@@ -32,6 +32,3 @@ class Book(models.Model):
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:books-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
return
reverse
(
'bookshelf:books-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_home_url
(
self
):
return
reverse
(
'bookshelf:books-list'
)
albertgagalac_reading/albertgagalac_reading/bookshelf/templates/bookshelf/author_detail.html
View file @
c1006fc4
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
{% block css %}
{% block css %}
h1 {
h1 {
padding-top: 2%;
padding-top: 2%;
font-family:'Comic Sans MS',cursive;
}
}
h3 {
h3 {
font-family:'Comic Sans MS',cursive;
font-family:'Comic Sans MS',cursive;
...
@@ -14,9 +15,17 @@
...
@@ -14,9 +15,17 @@
{% block title %}{{object}}{% endblock %}
{% block title %}{{object}}{% endblock %}
{% block heading %}{{object}}{% endblock %}
{% block heading %}{{object}}{% endblock %}
{% block content %}
{% block content %}
<h3>
Age:
</h3>
{{object.age}}
<br>
<h3>
Age:
</h3>
{{object.age}}
<br>
<h3>
Nationality:
</h3>
{{object.nationality}}
<br>
<h3>
Nationality:
</h3>
{{object.nationality}}
<br>
<h3>
Bio:
</h3>
{{object.bio}}
<h3>
Bio:
</h3>
{{object.bio}}
<h1>
Books by {{object}} I love:
</h1>
{% for book in book_list %}
<a
href=
"{{ book.get_absolute_url }}"
>
{{book.title}}
</a>
<br><br>
{% endfor %}
<br><br><br><a
href=
"/home/ "
>
Home
</a>
|
<a
href=
"/books/ "
>
Books
</a>
|
<a
href=
"/authors/ "
>
Authors
</a>
<br><br><br><a
href=
"/home/ "
>
Home
</a>
|
<a
href=
"/books/ "
>
Books
</a>
|
<a
href=
"/authors/ "
>
Authors
</a>
{% endblock %}
{% endblock %}
\ No newline at end of file
albertgagalac_reading/albertgagalac_reading/bookshelf/templates/bookshelf/book_list.html
View file @
c1006fc4
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
{% block css %}
{% block css %}
h1 {
h1 {
padding-top: 80px;
padding-top: 80px;
color: deep-blue;
}
}
{% endblock %}
{% endblock %}
...
@@ -12,8 +11,10 @@
...
@@ -12,8 +11,10 @@
{% block heading %}Burt's Favorite Books{% endblock %}
{% block heading %}Burt's Favorite Books{% endblock %}
{% block content %}
{% block content %}
{% for object in object_list %}
{% for object in object_list %}
<a
href=
"{{ object.get_absolute_url }}"
>
{{object.title}}
</a>
<a
href=
"{{ object.get_absolute_url }}"
>
<br><br>
{{object.title}}
</a>
<br><br>
{% endfor %}
<br>
{% endfor %}
<br>
<a
href=
"/home/ "
>
Home
</a>
|
<a
href=
"/authors/"
>
Authors
</a>
<a
href=
"/home/ "
>
Home
</a>
|
<a
href=
"/authors/"
>
Authors
</a>
...
...
albertgagalac_reading/albertgagalac_reading/bookshelf/urls.py
View file @
c1006fc4
...
@@ -5,7 +5,6 @@ from .views import (
...
@@ -5,7 +5,6 @@ from .views import (
home
,
BookListView
,
AuthorListView
home
,
BookListView
,
AuthorListView
)
)
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
"authors/"
,
AuthorListView
.
as_view
(),
name
=
"author-list"
),
path
(
"authors/"
,
AuthorListView
.
as_view
(),
name
=
"author-list"
),
path
(
"books/"
,
BookListView
.
as_view
(),
name
=
"books-list"
),
path
(
"books/"
,
BookListView
.
as_view
(),
name
=
"books-list"
),
...
...
albertgagalac_reading/albertgagalac_reading/bookshelf/views.py
View file @
c1006fc4
...
@@ -16,6 +16,11 @@ class BookDetailView(DetailView):
...
@@ -16,6 +16,11 @@ class BookDetailView(DetailView):
class
AuthorDetailView
(
DetailView
):
class
AuthorDetailView
(
DetailView
):
model
=
Author
model
=
Author
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'book_list'
]
=
Book
.
objects
.
filter
(
author
=
self
.
object
)
return
context
class
BookListView
(
ListView
):
class
BookListView
(
ListView
):
model
=
Book
model
=
Book
...
...
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