Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
ap-11_django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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-11_django
Commits
543dcca8
Commit
543dcca8
authored
1 year ago
by
Давид Ли
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webinar 21
parent
d4d90c52
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
23 deletions
+12
-23
urls.cpython-311.pyc
my_project/core/__pycache__/urls.cpython-311.pyc
+0
-0
urls.py
my_project/core/urls.py
+2
-1
views.cpython-311.pyc
my_project/web/__pycache__/views.cpython-311.pyc
+0
-0
article.html
my_project/web/templates/article.html
+1
-19
views.py
my_project/web/views.py
+9
-3
No files found.
my_project/core/__pycache__/urls.cpython-311.pyc
View file @
543dcca8
No preview for this file type
This diff is collapsed.
Click to expand it.
my_project/core/urls.py
View file @
543dcca8
...
@@ -22,5 +22,6 @@ from web import views
...
@@ -22,5 +22,6 @@ from web import views
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
views
.
index_view
),
path
(
''
,
views
.
index_view
),
path
(
'articles/add/'
,
views
.
article_create_view
)
path
(
'articles/add/'
,
views
.
article_create_view
,
name
=
'articles-add'
),
path
(
'articles/<int:id>'
,
views
.
article_detail_view
,
name
=
'articles-detail'
),
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
This diff is collapsed.
Click to expand it.
my_project/web/__pycache__/views.cpython-311.pyc
View file @
543dcca8
No preview for this file type
This diff is collapsed.
Click to expand it.
my_project/web/templates/article.html
View file @
543dcca8
...
@@ -6,25 +6,7 @@
...
@@ -6,25 +6,7 @@
</head>
</head>
<body>
<body>
<h1>
Create Article
</h1>
<h1>
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=
"content"
></textarea><br/>
<label>
Author:
</label><br/>
<input
type=
"text"
name=
"author"
/><br/>
<br/>
<input
type=
"submit"
value=
"Send"
/>
</form>
{{ calculate_result }}
<h1>
Future article:
</h1>
<h2>
{{ title }}
</h2>
<h2>
{{ title }}
</h2>
<p>
{{ content }}
</p>
<p>
{{ content }}
</p>
...
...
This diff is collapsed.
Click to expand it.
my_project/web/views.py
View file @
543dcca8
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
def
index_view
(
request
):
def
index_view
(
request
):
...
@@ -19,7 +19,8 @@ def article_create_view(request):
...
@@ -19,7 +19,8 @@ def article_create_view(request):
context
=
{}
context
=
{}
if
request
.
method
==
'GET'
:
if
request
.
method
==
'GET'
:
print
(
request
.
GET
.
get
(
'name'
))
print
(
request
.
GET
.
get
(
'name'
))
# return render(request, 'article_create.html')
return
render
(
request
,
'article_create.html'
)
elif
request
.
method
==
'POST'
:
elif
request
.
method
==
'POST'
:
print
(
request
.
POST
)
print
(
request
.
POST
)
data
=
request
.
POST
data
=
request
.
POST
...
@@ -29,4 +30,9 @@ def article_create_view(request):
...
@@ -29,4 +30,9 @@ def article_create_view(request):
'author'
:
data
.
get
(
'author'
)
'author'
:
data
.
get
(
'author'
)
}
}
return
render
(
request
,
'article.html'
,
context
)
return
redirect
(
'articles-add'
,
foo
=
'bar'
)
# /articles/{id}
def
article_detail_view
(
request
,
title
:
str
):
return
render
(
request
,
'article.html'
,
context
=
{
'title'
:
title
})
This diff is collapsed.
Click to expand it.
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