Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
ap4-HW-64-issatayev-adlet
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
Isataev Adlet
ap4-HW-64-issatayev-adlet
Commits
cbad5e75
Commit
cbad5e75
authored
Nov 03, 2021
by
Isataev Adlet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Создал модель проекта, вьюху для листа и создал базовый шаблон
parent
7e2bcfbd
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
101 additions
and
5 deletions
+101
-5
requirements.txt
requirements.txt
+1
-0
settings.py
source/speed_dating/settings.py
+5
-1
urls.py
source/speed_dating/urls.py
+3
-1
.gitignore
source/uploads/.gitignore
+2
-0
admin.py
source/webapp/admin.py
+5
-1
0001_initial.py
source/webapp/migrations/0001_initial.py
+32
-0
0002_restaurant_photo.py
source/webapp/migrations/0002_restaurant_photo.py
+18
-0
models.py
source/webapp/models.py
+25
-1
base.html
source/webapp/templates/base.html
+0
-0
event_list.html
source/webapp/templates/event_list.html
+0
-0
views.py
source/webapp/views.py
+10
-1
No files found.
requirements.txt
View file @
cbad5e75
...
...
@@ -2,3 +2,4 @@ asgiref==3.4.1
Django
==3.2.9
pytz
==2021.3
sqlparse
==0.4.2
Pillow
==8.4.0
source/speed_dating/settings.py
View file @
cbad5e75
...
...
@@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import
os
from
pathlib
import
Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
...
...
@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'webapp'
]
MIDDLEWARE
=
[
...
...
@@ -123,3 +124,6 @@ STATIC_URL = '/static/'
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
"uploads"
)
MEDIA_URL
=
"/uploads/"
source/speed_dating/urls.py
View file @
cbad5e75
...
...
@@ -13,9 +13,11 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from
django.conf
import
settings
from
django.conf.urls.static
import
static
from
django.contrib
import
admin
from
django.urls
import
path
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
]
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
source/uploads/.gitignore
0 → 100644
View file @
cbad5e75
*
!.gitignore
\ No newline at end of file
source/webapp/admin.py
View file @
cbad5e75
from
django.contrib
import
admin
from
webapp.models
import
Restaurant
,
Event
admin
.
site
.
register
(
Restaurant
)
admin
.
site
.
register
(
Event
)
# Register your models here.
source/webapp/migrations/0001_initial.py
0 → 100644
View file @
cbad5e75
# Generated by Django 3.2.9 on 2021-11-03 08:30
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Restaurant'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
30
,
verbose_name
=
'Название заведения'
)),
(
'address'
,
models
.
CharField
(
max_length
=
70
,
verbose_name
=
'Адрес'
)),
(
'description'
,
models
.
TextField
(
max_length
=
1000
,
verbose_name
=
'Описание заведения'
)),
],
),
migrations
.
CreateModel
(
name
=
'Event'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'date'
,
models
.
DateTimeField
(
verbose_name
=
'Дата'
)),
(
'place'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'Place'
,
to
=
'webapp.restaurant'
,
verbose_name
=
'Место проведения'
)),
],
),
]
source/webapp/migrations/0002_restaurant_photo.py
0 → 100644
View file @
cbad5e75
# Generated by Django 3.2.9 on 2021-11-03 08:41
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'webapp'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'restaurant'
,
name
=
'photo'
,
field
=
models
.
ImageField
(
default
=
1
,
upload_to
=
'photo'
,
verbose_name
=
'Фото заведения'
),
),
]
source/webapp/models.py
View file @
cbad5e75
from
django.db
import
models
# Create your models here.
class
Restaurant
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
30
,
verbose_name
=
"Название заведения"
)
address
=
models
.
CharField
(
max_length
=
70
,
verbose_name
=
"Адрес"
)
photo
=
models
.
ImageField
(
upload_to
=
"photo"
,
default
=
1
,
verbose_name
=
"Фото заведения"
)
description
=
models
.
TextField
(
max_length
=
1000
,
verbose_name
=
"Описание заведения"
)
def
__str__
(
self
):
return
f
'{self.name}'
class
Event
(
models
.
Model
):
place
=
models
.
ForeignKey
(
Restaurant
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
"Место проведения"
,
related_name
=
"Place"
)
date
=
models
.
DateTimeField
(
verbose_name
=
"Дата"
)
def
__str__
(
self
):
return
f
'{self.place}'
source/webapp/templates/base.html
0 → 100644
View file @
cbad5e75
source/webapp/templates/event_list.html
0 → 100644
View file @
cbad5e75
source/webapp/views.py
View file @
cbad5e75
from
django.shortcuts
import
render
from
django.views.generic
import
ListView
from
webapp.models
import
Event
class
EventView
(
ListView
):
model
=
Event
template_name
=
"event_list.html"
ordering
=
[
"date"
]
# Create your views here.
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