Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coursework
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
Борис Ким
coursework
Commits
a29d0aaf
Commit
a29d0aaf
authored
Oct 30, 2021
by
Борис Ким
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Создал модели и применил миграции. Добавил приложение в настройки
parent
2940da73
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
13 deletions
+124
-13
settings.py
source/portal/settings.py
+7
-12
0001_initial.py
source/webapp/migrations/0001_initial.py
+56
-0
models.py
source/webapp/models.py
+56
-1
courses.html
source/webapp/templates/courses/courses.html
+0
-0
courses_views.py
source/webapp/views/courses_views.py
+5
-0
No files found.
source/portal/settings.py
View file @
a29d0aaf
"""
import
os
Django settings for portal project.
Generated by 'django-admin startproject' using Django 3.2.
For more information on this file, see
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/
"""
from
pathlib
import
Path
from
pathlib
import
Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR
=
Path
(
__file__
)
.
resolve
()
.
parent
.
parent
BASE_DIR
=
Path
(
__file__
)
.
resolve
()
.
parent
.
parent
...
@@ -37,6 +27,7 @@ INSTALLED_APPS = [
...
@@ -37,6 +27,7 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'django.contrib.staticfiles'
,
'webapp'
]
]
MIDDLEWARE
=
[
MIDDLEWARE
=
[
...
@@ -123,3 +114,7 @@ STATIC_URL = '/static/'
...
@@ -123,3 +114,7 @@ STATIC_URL = '/static/'
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'media'
)
MEDIA_URL
=
'/media/'
\ No newline at end of file
source/webapp/migrations/0001_initial.py
0 → 100644
View file @
a29d0aaf
# Generated by Django 3.2.8 on 2021-10-30 16:52
from
django.conf
import
settings
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Specialization'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'spec_name'
,
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'spec_name'
)),
],
),
migrations
.
CreateModel
(
name
=
'Group'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'group_name'
,
models
.
CharField
(
max_length
=
50
,
verbose_name
=
'group_name'
)),
(
'specialization'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'webapp.specialization'
,
verbose_name
=
'specialization'
)),
(
'students'
,
models
.
ManyToManyField
(
related_name
=
'students'
,
to
=
settings
.
AUTH_USER_MODEL
,
verbose_name
=
'students'
)),
],
),
migrations
.
CreateModel
(
name
=
'Course'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'title'
,
models
.
CharField
(
max_length
=
50
,
verbose_name
=
'title'
)),
(
'description'
,
models
.
TextField
(
max_length
=
2000
,
verbose_name
=
'description'
)),
(
'start_date'
,
models
.
DateField
(
verbose_name
=
'Start date'
)),
(
'group'
,
models
.
ManyToManyField
(
related_name
=
'groups'
,
to
=
'webapp.Group'
,
verbose_name
=
'group'
)),
(
'teacher'
,
models
.
ForeignKey
(
default
=
1
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_DEFAULT
,
to
=
settings
.
AUTH_USER_MODEL
,
verbose_name
=
'teacher'
)),
],
),
migrations
.
CreateModel
(
name
=
'Class'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'title'
,
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'title'
)),
(
'description'
,
models
.
TextField
(
max_length
=
2000
,
verbose_name
=
'description'
)),
(
'file'
,
models
.
FileField
(
upload_to
=
'uploads/'
)),
(
'created_at'
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
'updated_at'
,
models
.
DateTimeField
(
auto_now
=
True
)),
(
'course'
,
models
.
ManyToManyField
(
related_name
=
'courses'
,
to
=
'webapp.Course'
,
verbose_name
=
'course'
)),
],
),
]
source/webapp/models.py
View file @
a29d0aaf
from
django.db
import
models
from
django.db
import
models
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
User
# class Student(User):
# name = models.CharField(max_length=50, verbose_name='name')
# surname = models.CharField(max_length=50, verbose_name='name')
# group = models.ForeignKey('webapp.Group', on_delete=models.CASCADE, verbose_name='group')
# course = models.ManyToManyField('webapp.Course', verbose_name='course', related_name='courses')
# adviser = models.ForeignKey('webapp.Teacher', on_delete=models.CASCADE, verbose_name='adviser')
# admission_date = models.DateField(('Admission date'), auto_now=False, auto_now_add=False)
# end_date = models.DateField(('End date'), auto_now=False, auto_now_add=False)
# class Teacher(models.Model):
# name = models.CharField(max_length=50, verbose_name='name')
# surname = models.CharField(max_length=50, verbose_name='name')
class
Course
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
,
verbose_name
=
'title'
)
description
=
models
.
TextField
(
max_length
=
2000
,
verbose_name
=
'description'
)
group
=
models
.
ManyToManyField
(
'webapp.Group'
,
verbose_name
=
'group'
,
related_name
=
'groups'
)
teacher
=
models
.
ForeignKey
(
get_user_model
(),
on_delete
=
models
.
SET_DEFAULT
,
verbose_name
=
'teacher'
,
default
=
1
)
start_date
=
models
.
DateField
((
'Start date'
),
auto_now
=
False
,
auto_now_add
=
False
)
def
__str__
(
self
):
return
self
.
title
class
Group
(
models
.
Model
):
group_name
=
models
.
CharField
(
max_length
=
50
,
verbose_name
=
'group_name'
)
specialization
=
models
.
ForeignKey
(
'webapp.Specialization'
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
'specialization'
)
students
=
models
.
ManyToManyField
(
get_user_model
(),
verbose_name
=
'students'
,
related_name
=
'students'
)
def
__str__
(
self
):
return
self
.
group_name
class
Class
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'title'
)
description
=
models
.
TextField
(
max_length
=
2000
,
verbose_name
=
'description'
)
file
=
models
.
FileField
(
upload_to
=
'uploads/'
)
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
updated_at
=
models
.
DateTimeField
(
auto_now
=
True
)
course
=
models
.
ManyToManyField
(
'webapp.Course'
,
verbose_name
=
'course'
,
related_name
=
'courses'
)
def
__str__
(
self
):
return
self
.
title
class
Specialization
(
models
.
Model
):
spec_name
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'spec_name'
)
def
__str__
(
self
):
return
self
.
spec_name
\ No newline at end of file
# Create your models here.
source/webapp/templates/courses/courses.html
0 → 100644
View file @
a29d0aaf
source/webapp/views.py
→
source/webapp/views
/courses_views
.py
View file @
a29d0aaf
from
django.shortcuts
import
render
from
django.shortcuts
import
render
# Create your views here.
def
view
(
request
):
return
render
(
request
,
'courses.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