Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
migs_atienza_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
Migs Atienza
migs_atienza_reading
Commits
d272edd0
Commit
d272edd0
authored
Apr 11, 2023
by
Migs Atienza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished books.html
parent
6439acda
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
3 deletions
+43
-3
models.cpython-39.pyc
...ienza_reading/bookshelf/__pycache__/models.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
...atienza_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...tienza_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
models.py
migs_atienza_reading/bookshelf/models.py
+4
-0
books.html
..._atienza_reading/bookshelf/templates/bookshelf/books.html
+19
-0
urls.py
migs_atienza_reading/bookshelf/urls.py
+4
-2
views.py
migs_atienza_reading/bookshelf/views.py
+16
-1
No files found.
migs_atienza_reading/bookshelf/__pycache__/models.cpython-39.pyc
View file @
d272edd0
No preview for this file type
migs_atienza_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
d272edd0
No preview for this file type
migs_atienza_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
d272edd0
No preview for this file type
migs_atienza_reading/bookshelf/models.py
View file @
d272edd0
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
class
Author
(
models
.
Model
):
...
@@ -23,4 +24,7 @@ class Book(models.Model):
...
@@ -23,4 +24,7 @@ class Book(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
title
)
return
'{}'
.
format
(
self
.
title
)
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:books_details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
# Create your models here.
# Create your models here.
migs_atienza_reading/bookshelf/templates/bookshelf/books.html
0 → 100644
View file @
d272edd0
{% extends 'base.html' %}
{% block title %}My Favorite Books{% endblock %}
{% block heading %}
<center>
Migs' Favorite Books
</center>
{% endblock %}
{% block content %}
<center>
<ul>
{% for object in object_list %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.title }}
</a>
</li>
{% endfor %}
</ul>
</center>
{% endblock %}
{% block links %}
<center><br/><br/><br/><br/><br/>
<a
href=
"home"
>
Home
</a>
<a
href=
"authors"
>
Authors
</a></center>
{% endblock %}
migs_atienza_reading/bookshelf/urls.py
View file @
d272edd0
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
,
home_view
from
.views
import
index
,
home_view
,
BooksListView
,
BooksDetailView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'home'
,
home_view
,
name
=
'home_view'
)
path
(
'home'
,
home_view
,
name
=
'home_view'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books_list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books_details'
),
]
]
app_name
=
"<bookshelf>"
app_name
=
"<bookshelf>"
...
...
migs_atienza_reading/bookshelf/views.py
View file @
d272edd0
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Author
,
Book
def
index
(
request
):
def
index
(
request
):
return
request
(
'Hello World! This came from the index view'
)
return
request
(
'Hello World! This came from the index view'
)
def
home_view
(
request
):
def
home_view
(
request
):
return
render
(
request
,
'bookshelf/home.html'
)
return
render
(
request
,
'bookshelf/home.html'
)
class
BooksListView
(
ListView
):
model
=
Book
template_name
=
"bookshelf/books.html"
class
BooksDetailView
(
DetailView
):
model
=
Book
template_name
=
"bookshelf/books_details.html"
# Create your views here.
# Create your views here.
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