Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cheskahung_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
Cheska Hung
cheskahung_reading
Commits
9140a81c
Commit
9140a81c
authored
Mar 28, 2023
by
Cheska Hung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final working verision
parent
9eff115d
Pipeline
#3052
canceled with stages
Changes
8
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
2 deletions
+29
-2
models.cpython-311.pyc
bookshelf/__pycache__/models.cpython-311.pyc
+0
-0
views.cpython-311.pyc
bookshelf/__pycache__/views.cpython-311.pyc
+0
-0
0003_alter_books_author.py
bookshelf/migrations/0003_alter_books_author.py
+19
-0
0003_alter_books_author.cpython-311.pyc
...tions/__pycache__/0003_alter_books_author.cpython-311.pyc
+0
-0
models.py
bookshelf/models.py
+1
-1
views.py
bookshelf/views.py
+2
-0
db.sqlite3
db.sqlite3
+0
-0
authors_details.html
templates/authors_details.html
+7
-1
No files found.
bookshelf/__pycache__/models.cpython-311.pyc
View file @
9140a81c
No preview for this file type
bookshelf/__pycache__/views.cpython-311.pyc
View file @
9140a81c
No preview for this file type
bookshelf/migrations/0003_alter_books_author.py
0 → 100644
View file @
9140a81c
# Generated by Django 4.1.7 on 2023-03-28 13:34
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0002_alter_books_isbn'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'books'
,
name
=
'author'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'books'
,
to
=
'bookshelf.author'
),
),
]
bookshelf/migrations/__pycache__/0003_alter_books_author.cpython-311.pyc
0 → 100644
View file @
9140a81c
File added
bookshelf/models.py
View file @
9140a81c
...
@@ -15,7 +15,7 @@ class Author(models.Model):
...
@@ -15,7 +15,7 @@ class Author(models.Model):
class
Books
(
models
.
Model
):
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
200
)
title
=
models
.
CharField
(
max_length
=
200
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
Author
,
related_name
=
"books"
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
max_length
=
200
)
publisher
=
models
.
CharField
(
max_length
=
200
)
year_published
=
models
.
DateField
()
year_published
=
models
.
DateField
()
ISBN
=
models
.
PositiveIntegerField
(
ISBN
=
models
.
PositiveIntegerField
(
...
...
bookshelf/views.py
View file @
9140a81c
...
@@ -29,4 +29,6 @@ class AuthorListView(ListView):
...
@@ -29,4 +29,6 @@ class AuthorListView(ListView):
class
AuthorDetailView
(
DetailView
):
class
AuthorDetailView
(
DetailView
):
model
=
Author
model
=
Author
queryset
=
Author
.
objects
.
all
()
template_name
=
'authors_details.html'
template_name
=
'authors_details.html'
context_object_name
=
'authors'
db.sqlite3
View file @
9140a81c
No preview for this file type
templates/authors_details.html
View file @
9140a81c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<h1>
{{object.first_name}}{{object.last_name}}
</h1>
<h1>
{{object.first_name}}{{object.last_name}}
</h1>
<h2>
{{object.age}}
</h2>
<h2>
{{object.age}}
</h2>
<h2>
{{object.nationality}}
</h2>
<h2>
{{object.nationality}}
</h2>
<h2>
{{
object
.bio}}
</h2>
<h2>
{{
authors
.bio}}
</h2>
{% for Books in object_list %}
{% for Books in object_list %}
<li>
<li>
...
@@ -18,6 +18,12 @@
...
@@ -18,6 +18,12 @@
{% endfor %}
{% endfor %}
<br><br>
<br><br>
<h2>
Books by {{object.first_name}}{{object.last_name}} that I love:
</h2>
<h2>
Books by {{object.first_name}}{{object.last_name}} that I love:
</h2>
{% for books in authors.books.all %}
<a
href=
"http://127.0.0.1:8000/books/{{ books.pk }}/details"
>
{{books.title}}
</a>
<br>
{% endfor %}
<br><br>
<br><br>
<a
href=
"/books"
>
Books
</a>
<a
href=
"/books"
>
Books
</a>
<a
href=
"/authors"
>
Authors
</a>
<a
href=
"/authors"
>
Authors
</a>
...
...
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