Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ejmejilla_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
EJ Mejilla
ejmejilla_reading
Commits
a91fcf1e
Commit
a91fcf1e
authored
Mar 28, 2023
by
EJ Mejilla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created the templates for all the required urls
parent
39a03f63
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
168 additions
and
8 deletions
+168
-8
models.py
ejmejilla_reading/bookshelf/models.py
+10
-0
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+33
-0
authors.html
ejmejilla_reading/bookshelf/templates/bookshelf/authors.html
+19
-0
book_details.html
...a_reading/bookshelf/templates/bookshelf/book_details.html
+22
-0
books.html
ejmejilla_reading/bookshelf/templates/bookshelf/books.html
+22
-0
home.html
ejmejilla_reading/bookshelf/templates/bookshelf/home.html
+15
-0
urls.py
ejmejilla_reading/bookshelf/urls.py
+6
-2
views.py
ejmejilla_reading/bookshelf/views.py
+25
-4
settings.py
ejmejilla_reading/ejmejilla_reading/settings.py
+1
-1
urls.py
ejmejilla_reading/ejmejilla_reading/urls.py
+1
-1
base.html
ejmejilla_reading/templates/base.html
+14
-0
No files found.
ejmejilla_reading/bookshelf/models.py
View file @
a91fcf1e
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
200
,
blank
=
True
)
first_name
=
models
.
CharField
(
max_length
=
200
,
blank
=
True
)
...
@@ -10,6 +11,9 @@ class Author(models.Model):
...
@@ -10,6 +11,9 @@ class Author(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
f
"{self.first_name} {self.last_name}"
return
f
"{self.first_name} {self.last_name}"
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:author-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Books
(
models
.
Model
):
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
200
,
blank
=
True
)
title
=
models
.
CharField
(
max_length
=
200
,
blank
=
True
)
...
@@ -18,3 +22,9 @@ class Books(models.Model):
...
@@ -18,3 +22,9 @@ class Books(models.Model):
year_published
=
models
.
IntegerField
(
default
=
0
)
year_published
=
models
.
IntegerField
(
default
=
0
)
ISBN
=
models
.
IntegerField
(
default
=
0
)
ISBN
=
models
.
IntegerField
(
default
=
0
)
blurb
=
models
.
TextField
(
max_length
=
1000
,
blank
=
True
)
blurb
=
models
.
TextField
(
max_length
=
1000
,
blank
=
True
)
def
__str__
(
self
):
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:book-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
ejmejilla_reading/bookshelf/templates/bookshelf/author_details.html
0 → 100644
View file @
a91fcf1e
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }} {{object.last_name}} {% endblock %}
{% block content %}
<div
class=
"details"
>
<h1>
{{ object.first_name }} {{object.last_name}}
</h1>
<ul>
<li>
{{ object.age }}
</li>
<li>
{{ object.nationality }}
</li>
<li>
{{ object.bio }}
</li>
</ul>
</div>
<div
class=
"details"
>
<h2>
Books by {{object.first_name}} {{object.last_name}} I love:
</h2>
<ul>
{% for books in author.books_set.all %}
<li>
<a
href=
"{{books.get_absolute_url}}"
>
{{ books.title }}
</a>
</li>
{% endfor %}
</ul>
</div>
<ul
class=
"footer"
>
<li><a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a></li>
<li><a
href=
"{% url 'bookshelf:authors' %}"
>
Authors
</a></li>
<li><a
href=
"{% url 'bookshelf:books' %}"
>
Books
</a></li>
</ul>
{% endblock %}
ejmejilla_reading/bookshelf/templates/bookshelf/authors.html
0 → 100644
View file @
a91fcf1e
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Authors {% endblock %}
{% block content %}
<h1>
EJ's Favorite Authors:
</h1>
<ul
class=
"list"
>
{% for object in object_list %}
<li>
<a
href=
"{{object.get_absolute_url}}"
>
{{object.first_name}} {{object.last_name}}
</a>
</li>
{% endfor %}
</ul>
<ul
class=
"footer"
>
<li><a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a></li>
<li><a
href=
"{% url 'bookshelf:books' %}"
>
Books
</a></li>
</ul>
{% endblock %}
ejmejilla_reading/bookshelf/templates/bookshelf/book_details.html
0 → 100644
View file @
a91fcf1e
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.title }} {% endblock %}
{% block content %}
<div
class=
"details"
>
<h1>
{{ object.title }}
</h1>
<ul>
<li><a
href=
"{{ object.author.get_absolute_url }}"
>
{{object.author}}
</a></li>
<li>
{{ object.publisher }}
</li>
<li>
{{ object.year_published }}
</li>
<li>
{{ object.ISBN }}
</li>
<li>
{{ object.blurb }}
</li>
</ul>
</div>
<ul
class=
"footer"
>
<li><a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a></li>
<li><a
href=
"{% url 'bookshelf:authors' %}"
>
Authors
</a></li>
<li><a
href=
"{% url 'bookshelf:books' %}"
>
Books
</a></li>
</ul>
{% endblock %}
ejmejilla_reading/bookshelf/templates/bookshelf/books.html
0 → 100644
View file @
a91fcf1e
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Books {% endblock %}
{% block content %}
<div
class=
"list"
>
<h1>
EJ's Favorite Books:
</h1>
<ul>
{% for object in object_list %}
<li>
<a
href=
"{{object.get_absolute_url}}"
>
{{object.title}}
</a>
</li>
{% endfor %}
</ul>
</div>
<ul
class=
"footer"
>
<li><a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a></li>
<li><a
href=
"{% url 'bookshelf:authors' %}"
>
Authors
</a></li>
</ul>
{% endblock %}
ejmejilla_reading/bookshelf/templates/bookshelf/home.html
0 → 100644
View file @
a91fcf1e
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Books
&
Authors {% endblock %}
{% block content %}
<div
class=
"homepage"
>
<h1>
Welcome to EJ's Database of Favorite Books and Authors!
</h1>
<p>
I like a variety of books from YA novels to psychological horror :D
</p>
</div>
<ul
class=
"footer"
>
<li><a
href=
"{% url 'bookshelf:books' %}"
>
Books
</a></li>
<li><a
href=
"{% url 'bookshelf:authors' %}"
>
Authors
</a></li>
</ul>
{% endblock %}
ejmejilla_reading/bookshelf/urls.py
View file @
a91fcf1e
# bookshelf/urls.py
# bookshelf/urls.py
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
from
.views
import
home_view
,
BookDetailView
,
BookListView
,
AuthorDetailView
,
AuthorListView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
home_view
,
name
=
'home'
),
path
(
'books/'
,
BookListView
.
as_view
(
template_name
=
'bookshelf/books.html'
),
name
=
'books'
),
path
(
'books/<int:pk>/details/'
,
BookDetailView
.
as_view
(
template_name
=
"bookshelf/book_details.html"
),
name
=
'book-details'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(
template_name
=
'bookshelf/authors.html'
),
name
=
'authors'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(
template_name
=
'bookshelf/author_details.html'
),
name
=
'author-details'
),
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
ejmejilla_reading/bookshelf/views.py
View file @
a91fcf1e
# bookshelf/views.py
# appname/views.py
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
def
index
(
request
):
from
.models
import
Author
,
Books
return
HttpResponse
(
'Hello World! This came from the index view'
)
def
home_view
(
request
):
return
render
(
request
,
'bookshelf/home.html'
)
class
BookDetailView
(
DetailView
):
model
=
Books
class
BookListView
(
ListView
):
model
=
Books
class
AuthorDetailView
(
DetailView
):
model
=
Author
class
AuthorListView
(
ListView
):
model
=
Author
ejmejilla_reading/ejmejilla_reading/settings.py
View file @
a91fcf1e
...
@@ -57,7 +57,7 @@ ROOT_URLCONF = 'ejmejilla_reading.urls'
...
@@ -57,7 +57,7 @@ ROOT_URLCONF = 'ejmejilla_reading.urls'
TEMPLATES
=
[
TEMPLATES
=
[
{
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)
],
'APP_DIRS'
:
True
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'OPTIONS'
:
{
'context_processors'
:
[
'context_processors'
:
[
...
...
ejmejilla_reading/ejmejilla_reading/urls.py
View file @
a91fcf1e
...
@@ -18,5 +18,5 @@ from django.urls import include, path
...
@@ -18,5 +18,5 @@ from django.urls import include, path
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'bookshelf/'
,
include
(
'bookshelf.urls'
,
namespace
=
"bookshelf"
))
path
(
'bookshelf/'
,
include
(
'bookshelf.urls'
)),
]
]
ejmejilla_reading/templates/base.html
0 → 100644
View file @
a91fcf1e
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<link
rel=
"stylesheet"
href=
"style.css"
>
<title>
{% block title %}My amazing site{% endblock %}
</title>
{% block styles %}{% endblock %}
</head>
<body>
<div
id=
"content"
>
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
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