Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvaalvarez_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
Angelo Alvarez
alvaalvarez_reading
Commits
9fbb8919
Commit
9fbb8919
authored
Mar 27, 2023
by
Angelo Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created ListView for Model Books
parent
b4f04fc0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
3 deletions
+35
-3
urls.cpython-310.pyc
...lvarez_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...varez_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
books.html
alvaalvarez_reading/bookshelf/templates/events/books.html
+21
-0
urls.py
alvaalvarez_reading/bookshelf/urls.py
+2
-1
views.py
alvaalvarez_reading/bookshelf/views.py
+12
-2
No files found.
alvaalvarez_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
9fbb8919
No preview for this file type
alvaalvarez_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
9fbb8919
No preview for this file type
alvaalvarez_reading/bookshelf/templates/events/books.html
0 → 100644
View file @
9fbb8919
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h1>
Alva's Favorite Books
</h1>
<ul>
{% for book in books %}
<li><a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a></li>
{% endfor %}
</ul>
<hr>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<a
href=
"../home/"
>
Home
</a>
<a
href=
"../authors/"
>
Authors
</a>
</div>
{% endblock %}
alvaalvarez_reading/bookshelf/urls.py
View file @
9fbb8919
from
django.urls
import
path
from
.views
import
home
from
.views
import
home
,
BooksListView
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books'
)
]
# This might be needed, depending on your Django version
...
...
alvaalvarez_reading/bookshelf/views.py
View file @
9fbb8919
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
.models
import
Books
# Create your views here.
def
home
(
request
):
return
render
(
request
,
'events/home.html'
)
class
BooksListView
(
View
):
model
=
Books
def
get
(
self
,
request
):
booklist
=
Books
.
objects
.
all
()
return
render
(
request
,
'events/books.html'
,
{
'books'
:
booklist
})
\ 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