Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
ap-12_django
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
1
Merge Requests
1
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
Давид Ли
ap-12_django
Commits
7c041a43
Commit
7c041a43
authored
Dec 25, 2023
by
Давид Ли
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lesson 42
parent
c4ddd62e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
102 additions
and
12 deletions
+102
-12
settings.py
ap_12/core/settings.py
+4
-0
urls.py
ap_12/core/urls.py
+1
-0
bootstrap.min.css
ap_12/static/css/bootstrap.min.css
+6
-0
styles.css
ap_12/static/css/styles.css
+11
-0
spider_men.jpg
ap_12/static/img/spider_men.jpg
+0
-0
create.html
ap_12/templates/articles/create.html
+30
-0
detail.html
ap_12/templates/articles/detail.html
+17
-0
index.html
ap_12/templates/index.html
+7
-12
views.py
ap_12/webapp/views.py
+26
-0
No files found.
ap_12/core/settings.py
View file @
7c041a43
...
@@ -120,6 +120,10 @@ USE_TZ = True
...
@@ -120,6 +120,10 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.2/howto/static-files/
# https://docs.djangoproject.com/en/3.2/howto/static-files/
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
...
...
ap_12/core/urls.py
View file @
7c041a43
...
@@ -21,4 +21,5 @@ from webapp import views
...
@@ -21,4 +21,5 @@ from webapp import views
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'123'
,
views
.
index_view
),
path
(
'123'
,
views
.
index_view
),
path
(
'articles/add'
,
views
.
article_create_view
)
]
]
ap_12/static/css/bootstrap.min.css
0 → 100644
View file @
7c041a43
This source diff could not be displayed because it is too large. You can
view the blob
instead.
ap_12/static/css/styles.css
0 → 100644
View file @
7c041a43
body
{
font-family
:
Arial
,
sans-serif
;
margin
:
0
;
background-color
:
aqua
;
}
.container
{
margin
:
0
auto
;
width
:
80%
;
text-align
:
center
;
}
ap_12/static/img/spider_men.jpg
0 → 100644
View file @
7c041a43
358 KB
ap_12/templates/articles/create.html
0 → 100644
View file @
7c041a43
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Document
</title>
</head>
<body>
<h1>
Create Article
</h1>
<form
action=
"/articles/add"
method=
"post"
>
{% csrf_token %}
<label>
Title:
</label><br>
<input
type=
"text"
name=
"title"
>
<br>
<label>
Text:
</label><br>
<textarea
name=
"text"
></textarea><br>
<label>
Author:
</label><br>
<input
type=
"text"
name=
"author"
><br>
<br>
<input
type=
"submit"
value=
"Send"
>
</form>
</body>
</html>
\ No newline at end of file
ap_12/templates/articles/detail.html
0 → 100644
View file @
7c041a43
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Document
</title>
</head>
<body>
<h1>
New Article
</h1>
<h2>
{{ title }}
</h2>
<p>
{{ text }}
</p>
<p>
By: {{ author }}
</p>
</body>
</html>
\ No newline at end of file
ap_12/templates/index.html
View file @
7c041a43
{% load static %}
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"{% static "
css
/
styles
.
css
"
%}"
>
<link
rel=
"stylesheet"
href=
"{% static "
css
/
bootstrap
.
min
.
css
"
%}"
>
<title>
Document
</title>
<title>
Document
</title>
<style>
*
{
margin
:
0
;
}
.container
{
margin
:
0
auto
;
width
:
80%
;
text-align
:
center
;
}
</style>
</head>
</head>
<body>
<body>
<div
class=
"container"
>
<div
class=
"container"
>
<h1>
This is my first Django project!
</h1>
<h1>
This is my first Django project!
</h1>
<button
class=
"btn btn-success"
>
bootstrap connected
</button>
<img
src=
"{% static "
img
/
spider_men
.
jpg
"
%}"
alt=
""
>
</div>
</div>
</body>
</body>
...
...
ap_12/webapp/views.py
View file @
7c041a43
...
@@ -4,6 +4,32 @@ from django.shortcuts import render
...
@@ -4,6 +4,32 @@ from django.shortcuts import render
# MVC - Model View Controller
# MVC - Model View Controller
# MTV - Model Template View
# MTV - Model Template View
# <QueryDict: {'hello': ['world1', 'world2']}>
# GET - получение http://localhost:1027/123?hello=world
# http://localhost:1027/123?hello=world1&hello=world2
# POST - действие
def
index_view
(
request
):
def
index_view
(
request
):
return
render
(
request
,
'index.html'
)
return
render
(
request
,
'index.html'
)
# <QueryDict: {'csrfmiddlewaretoken': ['NSGuE2NGozjOQoH6d8d7CsBvW8jTmF57Hjbooz6VMoXTEIQkEynKqyeqiddle6e3'],
# 'title': ['article 1'], 'text': ['rewgsdgadgdsagdsagsdag'],
# 'author': ['anonymous author']}>
def
article_create_view
(
request
):
if
request
.
method
==
'GET'
:
return
render
(
request
,
'articles/create.html'
)
elif
request
.
method
==
'POST'
:
print
(
request
.
POST
)
context
=
{
'title'
:
request
.
POST
.
get
(
'title'
),
'text'
:
request
.
POST
.
get
(
'text'
),
'author'
:
request
.
POST
.
get
(
'author'
),
}
return
render
(
request
,
'articles/detail.html'
,
context
)
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