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
Commit
062771cb
authored
Jun 21, 2021
by
Владислав Андреев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lesson 37-2
parent
b9755297
Hide 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
...
@@ -19,4 +19,11 @@ def article_create_view(request):
...
@@ -19,4 +19,11 @@ def article_create_view(request):
articles_list
=
Article
.
objects
.
all
()
articles_list
=
Article
.
objects
.
all
()
return
render
(
request
,
'article/list.html'
,
context
=
{
return
render
(
request
,
'article/list.html'
,
context
=
{
'articles'
:
articles_list
'articles'
:
articles_list
})
})
\ No newline at end of file
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"
>
<div
class=
"row"
>
<meta
name=
"viewport"
<div
class=
"col-md-6"
>
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<form
action=
"{% url 'add_article' %}"
method=
"post"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
{% csrf_token %}
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
<div
class=
"mb-3"
>
<title>
Document
</title>
<label
for=
"title_input"
class=
"form-label"
>
Title
</label>
</head>
<input
type=
"text"
name=
"title"
class=
"form-control"
id=
"title_input"
placeholder=
"Название..."
>
<body>
</div>
<div
class=
"container"
>
<div
class=
"mb-3"
>
<div
class=
"row"
>
<label
for=
"content_input"
class=
"form-label"
>
Content
</label>
<div
class=
"col-md-6"
>
<textarea
name=
"content"
class=
"form-control"
id=
"content_input"
placeholder=
"Текст..."
></textarea>
<form
action=
"{% url 'add_article' %}"
method=
"post"
>
</div>
{% csrf_token %}
<div
class=
"mb-3"
>
<div
class=
"mb-3"
>
<label
for=
"author_input"
class=
"form-label"
>
Author
</label>
<label
for=
"title_input"
class=
"form-label"
>
Title
</label>
<input
type=
"text"
name=
"author"
class=
"form-control"
id=
"author_input"
placeholder=
"Автор..."
>
<input
type=
"text"
name=
"title"
class=
"form-control"
id=
"title_input"
placeholder=
"Название..."
>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-success"
>
Create
</button>
<div
class=
"mb-3"
>
</form>
<label
for=
"content_input"
class=
"form-label"
>
Content
</label>
<textarea
name=
"content"
class=
"form-control"
id=
"content_input"
placeholder=
"Текст..."
></textarea>
</div>
<div
class=
"mb-3"
>
<label
for=
"author_input"
class=
"form-label"
>
Author
</label>
<input
type=
"text"
name=
"author"
class=
"form-control"
id=
"author_input"
placeholder=
"Автор..."
>
</div>
<button
type=
"submit"
class=
"btn btn-success"
>
Create
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
{% endblock %}
</html>
\ No newline at end of file
\ 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"
>
<h4>
{{ message }}
</h4>
<meta
name=
"viewport"
<div
class=
"row"
>
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<div
class=
"col-md-6"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<h2>
Статья
</h2>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
<p>
{{ article.title }}
</p>
<title>
Document
</title>
<p>
{{ article.author }}
</p>
</head>
<p>
{{ article.content }}
</p>
<body>
<div
class=
"container"
>
<h4>
{{ message }}
</h4>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<h2>
Статья
</h2>
<p>
{{ article.title }}
</p>
<p>
{{ article.author }}
</p>
<p>
{{ article.content }}
</p>
</div>
</div>
</div>
</div>
</div>
</body>
{% endblock %}
</html>
\ No newline at end of file
\ 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"
<div
class=
"col-md-6"
>
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<ul>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
{% for article in articles %}
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin=
"anonymous"
>
<li>
{{ article }}
</li>
<title>
Document
</title>
{% endfor %}
</head>
</ul>
<body>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<ul>
{% for article in articles %}
<li>
{{ article }}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</body>
</div>
</html>
{% endblock %}
\ 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