Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Deokhyun_Lee_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
Deokhyun Lee
Deokhyun_Lee_reading
Commits
8ae0776b
Commit
8ae0776b
authored
Apr 25, 2023
by
Deokhyun Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now design is added with static folder as a proper path. setting.py also include this path
parent
a5d1ce08
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
5 deletions
+44
-5
settings.py
Deokhyun_Lee_reading/Deokhyun_Lee_reading/settings.py
+2
-1
add-author.html
...n_Lee_reading/bookshelf/templates/authors/add-author.html
+12
-0
book_details.html
...n_Lee_reading/bookshelf/templates/books/book_details.html
+4
-1
urls.py
Deokhyun_Lee_reading/bookshelf/urls.py
+2
-1
views.py
Deokhyun_Lee_reading/bookshelf/views.py
+15
-1
styles.css
Deokhyun_Lee_reading/static/styles.css
+7
-0
base.html
Deokhyun_Lee_reading/templates/base.html
+2
-1
No files found.
Deokhyun_Lee_reading/Deokhyun_Lee_reading/settings.py
View file @
8ae0776b
...
...
@@ -52,7 +52,8 @@ MIDDLEWARE = [
]
ROOT_URLCONF
=
'Deokhyun_Lee_reading.urls'
STATIC_URL
=
'/static/'
STATICFILES_DIRS
=
[
BASE_DIR
/
"static"
]
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
...
...
Deokhyun_Lee_reading/bookshelf/templates/authors/add-author.html
0 → 100644
View file @
8ae0776b
{% extends 'base.html'%}
{% block title %}
Add New Author
{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Add Author
</button>
</form>
{% endblock %}
\ No newline at end of file
Deokhyun_Lee_reading/bookshelf/templates/books/book_details.html
View file @
8ae0776b
...
...
@@ -22,5 +22,8 @@
{% else %}
<p>
No Available Books.
</p>
{% endif %}
<a
href=
"/home"
>
Home
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/books"
>
Books
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors"
>
Authors
</a>
<ul>
<li
><button
type=
"button"
onclick=
"alert('You pressed the button!')"
>
Click me!
</button></li>
<li><a
href=
"/home"
>
Home
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/books"
>
Books
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors"
>
Authors
</a></li>
</ul>
{% endblock %}
\ No newline at end of file
Deokhyun_Lee_reading/bookshelf/urls.py
View file @
8ae0776b
from
django.urls
import
path
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BookListView
,
BookDetailView
,
BookAddListView
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
AuthorAddListView
,
BookListView
,
BookDetailView
,
BookAddListView
urlpatterns
=
[
# for Home (landing page)
...
...
@@ -7,6 +7,7 @@ urlpatterns = [
# for Authors page
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author_detail'
),
path
(
'authors/add'
,
AuthorAddListView
.
as_view
(),
name
=
"add_author"
),
# for Books page
path
(
'books/'
,
BookListView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BookDetailView
.
as_view
(),
name
=
'book_detail'
),
...
...
Deokhyun_Lee_reading/bookshelf/views.py
View file @
8ae0776b
...
...
@@ -3,7 +3,7 @@ from django.shortcuts import render, redirect
from
django.views.generic
import
ListView
,
DetailView
,
CreateView
from
django.shortcuts
import
render
from
.models
import
Author
,
Book
from
.forms
import
AddBookForm
from
.forms
import
AddBookForm
,
AddAuthorForm
# View for Home (landing page)
class
HomeView
(
View
):
...
...
@@ -57,3 +57,17 @@ class BookAddListView(CreateView):
else
:
return
render
(
request
,
'book_details.html'
,
{
'form'
:
form
})
class
AuthorAddListView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
"authors/add-author.html"
def
post
(
self
,
request
):
form
=
AddAuthorForm
(
request
.
POST
)
if
form
.
is_valid
():
# onSave is called, the form will have essential data and this includes pk as well.
new_author
=
form
.
save
()
# pass the pk and redirect.
return
redirect
(
'author_detail'
,
pk
=
new_author
.
pk
)
else
:
return
render
(
request
,
'author_details.html'
,
{
'form'
:
form
})
\ No newline at end of file
Deokhyun_Lee_reading/
templates
/styles.css
→
Deokhyun_Lee_reading/
static
/styles.css
View file @
8ae0776b
.row
{
grid-row
:
1
/
span
2
;
}
ul
li
{
list-style-type
:
none
;
}
\ No newline at end of file
Deokhyun_Lee_reading/templates/base.html
View file @
8ae0776b
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<link
rel=
"styleshost"
href=
"styles.css"
>
{% load static %}
<link
rel=
"stylesheet"
href=
"{% static 'styles.css' %}"
>
<title>
{% block title %}{% endblock %}
</title>
</head>
<body>
...
...
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