Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
lesson_34
Project
Project
Details
Activity
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
Владислав Андреев
lesson_34
Commits
062771cb
Project 'vladislav_andreev/lesson_34' was moved to 'v/lesson_34'. Please update any links and bookmarks that may still have the old path.
Commit
062771cb
authored
Jun 21, 2021
by
Владислав Андреев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lesson 37-2
parent
b9755297
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
81 deletions
+105
-81
urls.py
article/urls.py
+3
-2
views.py
article/views.py
+8
-1
settings.py
article_lesson/settings.py
+4
-0
create.html
templates/article/create.html
+22
-33
detail.html
templates/article/detail.html
+11
-22
list.html
templates/article/list.html
+12
-23
base.html
templates/base.html
+45
-0
No files found.
article/urls.py
View file @
062771cb
from
django.urls
import
path
from
django.urls
import
path
from
article.views
import
article_create_view
from
article.views
import
article_create_view
,
article_list_view
urlpatterns
=
[
urlpatterns
=
[
path
(
'add/'
,
article_create_view
,
name
=
'add_article'
)
path
(
'add/'
,
article_create_view
,
name
=
'add_article'
),
path
(
'list/'
,
article_list_view
,
name
=
'article_list'
)
]
]
\ No newline at end of file
article/views.py
View file @
062771cb
...
@@ -20,3 +20,10 @@ def article_create_view(request):
...
@@ -20,3 +20,10 @@ def article_create_view(request):
return
render
(
request
,
'article/list.html'
,
context
=
{
return
render
(
request
,
'article/list.html'
,
context
=
{
'articles'
:
articles_list
'articles'
:
articles_list
})
})
def
article_list_view
(
request
):
articles_list
=
Article
.
objects
.
all
()
return
render
(
request
,
'article/list.html'
,
context
=
{
'articles'
:
articles_list
})
\ No newline at end of file
article_lesson/settings.py
View file @
062771cb
...
@@ -121,6 +121,10 @@ USE_TZ = True
...
@@ -121,6 +121,10 @@ USE_TZ = True
STATIC_URL
=
'/static/'
STATIC_URL
=
'/static/'
# STATICFILES_DIRS = [
# [BASE_DIR / "static"]
# ]
# Default primary key field type
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
...
...
templates/article/create.html
View file @
062771cb
<!doctype html>
{% extends 'base.html' %}
<html
lang=
"en"
>
<head>
{% block content %}
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
<title>
Document
</title>
</head>
<body>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
<form
action=
"{% url 'add_article' %}"
method=
"post"
>
<form
action=
"{% url 'add_article' %}"
method=
"post"
>
...
@@ -30,6 +21,4 @@
...
@@ -30,6 +21,4 @@
</form>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
</body>
\ No newline at end of file
</html>
\ No newline at end of file
templates/article/detail.html
View file @
062771cb
<!doctype html>
{% extends 'base.html' %}
<html
lang=
"en"
>
<head>
{% block content %}
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
<title>
Document
</title>
</head>
<body>
<div
class=
"container"
>
<h4>
{{ message }}
</h4>
<h4>
{{ message }}
</h4>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
...
@@ -19,6 +10,4 @@
...
@@ -19,6 +10,4 @@
<p>
{{ article.content }}
</p>
<p>
{{ article.content }}
</p>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
</body>
\ No newline at end of file
</html>
\ No newline at end of file
templates/article/list.html
View file @
062771cb
<!doctype html>
{% extends 'base.html' %}
<html
lang=
"en"
>
<head>
{% block content %}
<meta
charset=
"UTF-8"
>
<div
class=
"row"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
<title>
Document
</title>
</head>
<body>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
<ul>
<ul>
{% for article in articles %}
{% for article in articles %}
...
@@ -18,7 +9,5 @@
...
@@ -18,7 +9,5 @@
{% endfor %}
{% endfor %}
</ul>
</ul>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
</body>
</html>
\ No newline at end of file
templates/base.html
View file @
062771cb
{#{% load static %}#}
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
{#
<link
rel=
"stylesheet"
href=
"{% url 'css/style.css' %}"
>
#}
<title>
Document
</title>
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
>
<div
class=
"container-fluid"
>
<a
class=
"navbar-brand"
href=
"#"
>
Navbar
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-bs-toggle=
"collapse"
data-bs-target=
"#navbarNav"
aria-controls=
"navbarNav"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarNav"
>
<ul
class=
"navbar-nav"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link active"
aria-current=
"page"
href=
"#"
>
Home
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Features
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Pricing
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link disabled"
href=
"#"
tabindex=
"-1"
aria-disabled=
"true"
>
Disabled
</a>
</li>
</ul>
</div>
</div>
</nav>
<div
class=
"container"
>
{% block content %}
{% endblock %}
</div>
</body>
</html>
\ 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