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
d4d90c52
Commit
d4d90c52
authored
Jun 12, 2023
by
Давид Ли
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed lesson_42
parent
04f0bd74
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
38 deletions
+106
-38
styles.css
my_project/banana/css/styles.css
+1
-0
settings.cpython-311.pyc
my_project/core/__pycache__/settings.cpython-311.pyc
+0
-0
urls.cpython-311.pyc
my_project/core/__pycache__/urls.cpython-311.pyc
+0
-0
settings.py
my_project/core/settings.py
+7
-7
urls.py
my_project/core/urls.py
+3
-2
views.cpython-311.pyc
my_project/web/__pycache__/views.cpython-311.pyc
+0
-0
article.html
my_project/web/templates/article.html
+34
-0
article_create.html
my_project/web/templates/article_create.html
+28
-0
index.html
my_project/web/templates/index.html
+6
-20
views.py
my_project/web/views.py
+27
-9
No files found.
my_project/
static
/css/styles.css
→
my_project/
banana
/css/styles.css
View file @
d4d90c52
...
...
@@ -12,6 +12,7 @@ body {
font-family
:
Arial
,
sans-serif
;
font-size
:
16px
;
color
:
#444444
;
background-color
:
pink
;
}
.container
{
...
...
my_project/core/__pycache__/settings.cpython-311.pyc
View file @
d4d90c52
No preview for this file type
my_project/core/__pycache__/urls.cpython-311.pyc
View file @
d4d90c52
No preview for this file type
my_project/core/settings.py
View file @
d4d90c52
...
...
@@ -121,14 +121,14 @@ USE_TZ = True
STATIC_URL
=
'/static/'
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'
static
'
)
os
.
path
.
join
(
BASE_DIR
,
'
banana
'
)
]
# Media files
MEDIA_URL
=
'/media/'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
#
#
#
#
Media files
#
#
MEDIA_URL = '/media/'
#
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
...
...
my_project/core/urls.py
View file @
d4d90c52
...
...
@@ -17,9 +17,10 @@ from django.conf import settings
from
django.conf.urls.static
import
static
from
django.contrib
import
admin
from
django.urls
import
path
from
web
.views
import
index_view
from
web
import
views
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
index_view
)
path
(
''
,
views
.
index_view
),
path
(
'articles/add/'
,
views
.
article_create_view
)
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
my_project/web/__pycache__/views.cpython-311.pyc
View file @
d4d90c52
No preview for this file type
my_project/web/templates/article.html
0 → 100644
View file @
d4d90c52
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</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=
"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>
<p>
{{ content }}
</p>
<h5>
By: {{ author }}
</h5>
</body>
</html>
\ No newline at end of file
my_project/web/templates/article_create.html
0 → 100644
View file @
d4d90c52
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Create
</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=
"content"
></textarea><br/>
<label>
Author:
</label><br/>
<input
type=
"text"
name=
"author"
/><br/>
<br/>
<input
type=
"submit"
value=
"Send"
/>
</form>
</body>
</html>
my_project/web/templates/index.html
View file @
d4d90c52
...
...
@@ -15,26 +15,12 @@
<p>
This is my first Django project!
</p>
<h1>
{{ greetings|default:"Hello World!" }}
</h1>
{% lorem 5 random %}
{% now "SHORT_DATETIME_FORMAT" %}
{% for product, price in products.items %}
{% if forloop.first %}
<hr>
{% elif not forloop.first %}
{% else %}
{% endif %}
<h2>
{{ product }} - {{ price }}
</h2>
{% if forloop.last %}
<hr>
{% endif %}
{% empty %}
<h1>
There are no products :c
</h1>
{% endfor %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
<input
type=
"text"
name=
"name"
>
<input
type=
"text"
name=
"surname"
>
<input
type=
"submit"
value=
"Send"
>
</form>
<p>
Hello World!
</p>
</div>
...
...
my_project/web/views.py
View file @
d4d90c52
...
...
@@ -2,13 +2,31 @@ from django.shortcuts import render
def
index_view
(
request
):
return
render
(
request
,
'index.html'
,
context
=
{
'greetings'
:
'Hello AP-11!'
# 'products': {
# 'Banana': 120,
# 'Apple': 100,
# 'Bread': 70
# }
if
request
.
method
==
'POST'
:
print
(
request
.
POST
)
else
:
print
(
request
.
GET
)
print
(
request
.
GET
.
get
(
'name'
))
print
(
request
.
GET
.
getlist
(
'name'
))
return
render
(
request
,
'index.html'
,
context
=
{
'greetings'
:
'Hello AP-11!'
}
)
def
article_create_view
(
request
):
context
=
{}
if
request
.
method
==
'GET'
:
print
(
request
.
GET
.
get
(
'name'
))
# return render(request, 'article_create.html')
elif
request
.
method
==
'POST'
:
print
(
request
.
POST
)
data
=
request
.
POST
context
=
{
'title'
:
data
.
get
(
'title'
),
'content'
:
data
.
get
(
'content'
),
'author'
:
data
.
get
(
'author'
)
}
)
return
render
(
request
,
'article.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