├── .gitignore
├── lecture_1
└── firstapp
│ ├── app1
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── admin.py
│ ├── tests.py
│ ├── apps.py
│ ├── urls.py
│ └── views.py
│ ├── firstapp
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
│ ├── .idea
│ ├── vcs.xml
│ ├── .gitignore
│ ├── misc.xml
│ ├── inspectionProfiles
│ │ ├── profiles_settings.xml
│ │ └── Project_Default.xml
│ ├── modules.xml
│ └── firstapp.iml
│ └── manage.py
├── lecture_2
└── todo_project
│ ├── tasks
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── admin.py
│ ├── tests.py
│ ├── apps.py
│ ├── urls.py
│ └── views.py
│ ├── todo_project
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
│ ├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── misc.xml
│ └── todo_project.iml
│ ├── templates
│ ├── blog.html
│ ├── about.html
│ ├── index.html
│ └── base.html
│ └── manage.py
├── lecture_3
└── todo_project_2
│ ├── tasks
│ ├── __init__.py
│ ├── migrations
│ │ ├── __init__.py
│ │ └── 0001_initial.py
│ ├── tests.py
│ ├── admin.py
│ ├── views.py
│ ├── apps.py
│ └── models.py
│ ├── todo_project_day_2
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
│ ├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── misc.xml
│ └── todo_project_2.iml
│ └── manage.py
├── lecture_4
└── todo_project_4
│ ├── tasks
│ ├── __init__.py
│ ├── migrations
│ │ ├── __init__.py
│ │ ├── 0002_auto_20200919_1330.py
│ │ ├── 0003_auto_20200919_1349.py
│ │ └── 0001_initial.py
│ ├── tests.py
│ ├── views.py
│ ├── apps.py
│ ├── admin.py
│ └── models.py
│ ├── todo_project_4
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
│ ├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── misc.xml
│ └── todo_project_4.iml
│ └── manage.py
├── lecture_5
└── todo_project_5
│ ├── tasks
│ ├── __init__.py
│ ├── migrations
│ │ ├── __init__.py
│ │ └── 0001_initial.py
│ ├── tests.py
│ ├── apps.py
│ ├── urls.py
│ ├── forms.py
│ ├── models.py
│ ├── admin.py
│ └── views.py
│ ├── todo_project_5
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
│ ├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── misc.xml
│ └── todo_project_5.iml
│ ├── templates
│ └── tasks
│ │ ├── index.html
│ │ ├── new_task_2.html
│ │ ├── contact_us_2.html
│ │ ├── new_task.html
│ │ └── contact_us.html
│ └── manage.py
├── lecture_6
└── todo_project_6
│ ├── pages
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── urls.py
│ └── views.py
│ ├── tasks
│ ├── __init__.py
│ ├── migrations
│ │ ├── __init__.py
│ │ └── 0001_initial.py
│ ├── tests.py
│ ├── apps.py
│ ├── urls.py
│ ├── forms.py
│ ├── views.py
│ ├── models.py
│ └── admin.py
│ ├── accounts
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── admin.py
│ ├── tests.py
│ ├── apps.py
│ ├── urls.py
│ ├── forms.py
│ └── views.py
│ ├── todo_project_6
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
│ ├── .idea
│ ├── .gitignore
│ ├── vcs.xml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── modules.xml
│ ├── misc.xml
│ └── todo_project_6.iml
│ ├── templates
│ ├── tasks
│ │ ├── index.html
│ │ ├── add_tag.html
│ │ └── add_task.html
│ ├── pages
│ │ ├── about.html
│ │ ├── home.html
│ │ ├── dashboard.html
│ │ └── contact.html
│ └── accounts
│ │ ├── register.html
│ │ └── login.html
│ └── manage.py
├── lecture_1.md
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | **/venv/*
2 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/firstapp/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/todo_project/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/todo_project_4/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/todo_project_5/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/todo_project_6/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/todo_project_day_2/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/migrations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class App1Config(AppConfig):
5 | name = 'app1'
6 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TasksConfig(AppConfig):
5 | name = 'tasks'
6 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TasksConfig(AppConfig):
5 | name = 'tasks'
6 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TasksConfig(AppConfig):
5 | name = 'tasks'
6 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TasksConfig(AppConfig):
5 | name = 'tasks'
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class PagesConfig(AppConfig):
5 | name = 'pages'
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TasksConfig(AppConfig):
5 | name = 'tasks'
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class AccountsConfig(AppConfig):
5 | name = 'accounts'
6 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/templates/blog.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block page_body %}
4 | All our blogs live here
5 | {% endblock %}
6 |
7 | {% block title %}blog{% endblock %}
--------------------------------------------------------------------------------
/lecture_2/todo_project/templates/about.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block page_body %}
4 | Hello, this is the about page
5 | {% endblock %}
6 |
7 | {% block title %}about{% endblock %}
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/urls.py:
--------------------------------------------------------------------------------
1 | from . import views
2 | from django.urls import path
3 |
4 | urlpatterns = [
5 | path('xxxxxxx', views.index, name='index'),
6 | path('', views.index, name='index')
7 | ]
8 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from . import views
3 |
4 | urlpatterns = [
5 | path('add_task', views.add_task, name='add_task'),
6 | path('add_tag', views.add_tag, name='add_tag'),
7 | ]
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/app1/views.py:
--------------------------------------------------------------------------------
1 | from django.http import HttpResponse
2 | from django.shortcuts import render
3 |
4 | # Create your views here.
5 |
6 | def index(request):
7 | return HttpResponse("Hello, this app seems to be working fine.")
8 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 |
3 |
4 | class ContactForm(forms.Form):
5 | subject = forms.CharField(max_length=255)
6 | message = forms.CharField(max_length=65536, widget=forms.Textarea)
7 | sender = forms.EmailField()
8 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 | urlpatterns = [
5 | path('login/', views.login, name='login'),
6 | path('register/', views.register, name='register'),
7 | path('logout/', views.logout, name='logout'),
8 | ]
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/forms.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.forms import UserCreationForm
2 | from django.contrib.auth.models import User
3 |
4 |
5 | class CreateUserForm(UserCreationForm):
6 | class Meta:
7 | model = User
8 | fields = ['username', 'email', 'password1', 'password2']
9 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/templates/tasks/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | All the tasks
6 |
7 |
8 | All tasks
9 |
10 | {% for task in tasks %}
11 | - {{ task.content }}
12 | {% endfor %}
13 |
14 |
15 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from django.views.generic import TemplateView
3 |
4 | from . import views
5 |
6 | urlpatterns = [
7 | path('', views.index_page),
8 | path('about', TemplateView.as_view(template_name='about.html')),
9 | path('blog', TemplateView.as_view(template_name='blog.html')),
10 | ]
11 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/templates/tasks/new_task_2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Contact Us
6 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/templates/tasks/contact_us_2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Contact Us
6 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from . import views
3 |
4 | urlpatterns = [
5 | path('', views.index, name='tasks'),
6 | path('add_task', views.add_task, name='add_task'),
7 | path('add_task_2', views.add_task_2, name='add_task_2'),
8 | path('contact', views.contact, name='contact'),
9 | path('contact_2', views.contact_2, name='contact_2'),
10 | ]
11 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/.idea/todo_project.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block page_body %}
4 |
5 | This is the homepage of our website.
6 | The time right now is {{ cur_date }}
7 |
8 |
9 | These are the tasks that we have:
10 |
11 | {% for task in tasks %}
12 | - {{ task }}
13 | {% endfor %}
14 |
15 |
16 | {% endblock %}
17 |
18 | {% block title %}index{% endblock %}
19 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 | from django.views.generic import TemplateView
3 |
4 | from . import views
5 |
6 | urlpatterns = [
7 | path('', TemplateView.as_view(template_name='pages/home.html'), name='home'),
8 | path('about', TemplateView.as_view(template_name='pages/about.html'), name='about'),
9 | path('contact', views.contact, name='contact'),
10 | path('dashboard', views.dashboard, name='dashboard'),
11 | ]
12 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/tasks/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | All the tasks
6 |
7 |
8 | All tasks
9 |
10 | {% for task in tasks %}
11 | - {{ task.content }}
12 | {% endfor %}
13 |
14 | All tags
15 |
16 | {% for tag in tags %}
17 | - {{ tag.name }}
18 | {% endfor %}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/firstapp/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for firstapp project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'firstapp.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/firstapp/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for firstapp project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'firstapp.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 |
3 | from tasks.models import Task, Tag
4 |
5 |
6 | class TaskForm(forms.ModelForm):
7 | class Meta:
8 | model = Task
9 | fields = ['content', 'deadline', 'tags']
10 | widgets = {
11 | 'deadline': forms.DateTimeInput(attrs={'type': 'datetime-local'})
12 | }
13 |
14 |
15 | class TagForm(forms.ModelForm):
16 | class Meta:
17 | model = Tag
18 | fields = ['name']
19 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/tasks/add_tag.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Add Tag
6 |
7 |
8 | Add new Tag
9 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/tasks/add_task.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Add task
6 |
7 |
8 | Add new Task
9 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/pages/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | About Us
6 |
7 |
8 | About Us
9 | {% if request.user.is_authenticated %}
10 | Logout
11 | {% else %}
12 | Login
13 | {% endif %}
14 | Sign Up
15 |
16 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/todo_project/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for todo_project project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/todo_project/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for todo_project project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/templates/tasks/new_task.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | All the tasks
6 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/todo_project_4/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for todo_project_4 project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_4.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/todo_project_4/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for todo_project_4 project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_4.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/todo_project_5/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for todo_project_5 project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_5.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/todo_project_5/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for todo_project_5 project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_5.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/pages/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Todo App
6 |
7 |
8 | Welcome to Todo App
9 | {% if request.user.is_authenticated %}
10 | Logout
11 | {% else %}
12 | Login
13 | {% endif %}
14 | Sign Up
15 |
16 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/todo_project_6/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for todo_project_6 project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_6.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/todo_project_6/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for todo_project_6 project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_6.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/todo_project_day_2/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for todo_project_day_2 project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_day_2.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/todo_project_day_2/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for todo_project_day_2 project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_day_2.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/templates/tasks/contact_us.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Contact Us
6 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/accounts/register.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Sign Up
6 |
7 |
8 | Sign Up
9 |
10 |
19 | Login if you already have an account
20 |
21 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/forms.py:
--------------------------------------------------------------------------------
1 | from django import forms
2 |
3 | from tasks.models import Task
4 |
5 |
6 | class ContactForm(forms.Form):
7 | subject = forms.CharField(max_length=255)
8 | message = forms.CharField(max_length=65536, widget=forms.Textarea)
9 | sender = forms.EmailField()
10 |
11 |
12 | class TaskForm(forms.ModelForm):
13 | class Meta:
14 | model = Task
15 | fields = ['content', 'deadline', 'tags']
16 | widgets = {
17 | 'deadline': forms.DateTimeInput(attrs = {'type': 'datetime-local'})
18 | }
19 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/.idea/todo_project_2.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/.idea/todo_project_4.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/tasks/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 | from datetime import datetime
3 |
4 | # Django ORM (Object Relational Mapper)
5 |
6 | current_tasks = [
7 | 'Create a simple django project',
8 | 'Learn about the various template functions django provides',
9 | 'Learn how to deploy the project'
10 | ]
11 |
12 | # Create your views here.
13 | def index_page(request):
14 | return render(request, 'index.html',
15 | context={
16 | 'cur_date': str(datetime.now()),
17 | 'tasks': current_tasks,
18 | })
19 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/.idea/todo_project_5.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/.idea/todo_project_6.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/pages/dashboard.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Todo App
6 |
7 |
8 | Welcome, {{ request.user }}
9 |
10 | Logout
11 |
12 | My Tasks
13 |
14 | {% for task in tasks %}
15 | - {{ task }}
16 | {% endfor %}
17 |
18 | Add a new Task
19 |
20 | My Tags
21 |
22 | {% for tag in tags %}
23 | - {{ tag }}
24 | {% endfor %}
25 |
26 | Add a new Tag
27 |
28 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Todo App - {% block title %} {% endblock%}
6 |
7 |
15 | {% block extra_styles %} {% endblock %}
16 |
17 |
18 | {% block page_body %} {% endblock %}
19 |
20 |
--------------------------------------------------------------------------------
/lecture_1.md:
--------------------------------------------------------------------------------
1 | Why Django?
2 | -----------
3 | - web framework
4 | - extensively used
5 | - extremely Powerful, yet simple to use
6 | - Large websites - youtube, instagram, dropbox, ..
7 | - provides authentication and security out of the box
8 | - works well with all major database systems out there
9 | - first class community support
10 | - MVC framework
11 | - Scalable
12 |
13 | Why Pycharm?
14 | ------------
15 | - first class Django support
16 | - Community Editor is completely free
17 | - Pycharm automatically handles a lot of configuration and best practices for us
18 | - If you're a beginner, working with an IDE will help you learn faster
19 |
20 |
21 | Entire Django Documentation: https://buildmedia.readthedocs.org/media/pdf/django/latest/django.pdf
22 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'firstapp.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/pages/contact.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Contact Us
6 |
7 |
8 | Contact Us
9 |
18 | {% if request.user.is_authenticated %}
19 | Logout
20 | {% else %}
21 | Login
22 | {% endif %}
23 | Sign Up
24 |
25 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_4.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_5.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_6.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project_day_2.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/todo_project_4/urls.py:
--------------------------------------------------------------------------------
1 | """todo_project_4 URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path
18 |
19 | urlpatterns = [
20 | path('admin/', admin.site.urls),
21 | ]
22 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/todo_project_day_2/urls.py:
--------------------------------------------------------------------------------
1 | """todo_project_day_2 URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path
18 |
19 | urlpatterns = [
20 | path('admin/', admin.site.urls),
21 | ]
22 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/pages/views.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.decorators import login_required
2 | from django.shortcuts import render, redirect
3 | from django.contrib.auth.decorators import login_required
4 |
5 | from tasks.models import Tag, Task
6 | from .forms import ContactForm
7 |
8 |
9 | def contact(request):
10 | if request.method == 'POST':
11 | form = ContactForm(data=request.POST)
12 | if form.is_valid():
13 | # send email
14 | return redirect('tasks')
15 | else:
16 | form = ContactForm()
17 | return render(request, 'pages/contact.html', {'form': form})
18 |
19 |
20 | @login_required(login_url='login')
21 | def dashboard(request):
22 | user = request.user
23 | tasks = user.task_set.all()
24 | tags = user.tag_set.all()
25 | return render(request, 'pages/dashboard.html', {'tasks': tasks, 'tags': tags})
26 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/templates/accounts/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Login
6 |
7 |
8 | Login
9 |
25 | {% for message in messages %}
26 | {{ message }}
27 | {% endfor %}
28 | Create a new account
29 |
30 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/todo_project/urls.py:
--------------------------------------------------------------------------------
1 | """todo_project URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path, include
18 |
19 | urlpatterns = [
20 | path('tasks/', include('tasks.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/todo_project_5/urls.py:
--------------------------------------------------------------------------------
1 | """todo_project_5 URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path, include
18 |
19 | urlpatterns = [
20 | path('admin/', admin.site.urls),
21 | path('tasks/', include('tasks.urls')),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/firstapp/urls.py:
--------------------------------------------------------------------------------
1 | """firstapp URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path, include
18 |
19 | urlpatterns = [
20 | path('app1/', include('app1.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
24 | # http://localhost:8000/app1/
25 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/migrations/0002_auto_20200919_1330.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.1 on 2020-09-19 13:30
2 |
3 | import datetime
4 | from django.db import migrations, models
5 | from django.utils.timezone import utc
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('tasks', '0001_initial'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='task',
17 | name='created_at',
18 | field=models.DateTimeField(default=datetime.datetime(2020, 9, 19, 13, 30, 43, 199605, tzinfo=utc)),
19 | ),
20 | migrations.AlterField(
21 | model_name='task',
22 | name='deadline',
23 | field=models.DateTimeField(null=True),
24 | ),
25 | migrations.AlterField(
26 | model_name='task',
27 | name='tags',
28 | field=models.ManyToManyField(null=True, to='tasks.Tag'),
29 | ),
30 | ]
31 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/todo_project_6/urls.py:
--------------------------------------------------------------------------------
1 | """todo_project_6 URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path, include
18 |
19 | urlpatterns = [
20 | path('admin/', admin.site.urls),
21 | path('tasks/', include('tasks.urls')),
22 | path('', include('pages.urls')),
23 | path('', include('accounts.urls')),
24 | ]
25 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/views.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.decorators import login_required
2 | from django.shortcuts import render, redirect
3 |
4 | from .forms import TaskForm, TagForm
5 |
6 |
7 | @login_required(login_url='login')
8 | def add_task(request):
9 | if request.method == 'POST':
10 | form = TaskForm(data=request.POST)
11 | form.instance.user = request.user
12 | if form.is_valid():
13 | task = form.save()
14 | return redirect('dashboard')
15 | else:
16 | form = TaskForm()
17 | return render(request, 'tasks/add_task.html', {'form': form})
18 |
19 |
20 | @login_required(login_url='login')
21 | def add_tag(request):
22 | if request.method == 'POST':
23 | form = TagForm(data=request.POST)
24 | form.instance.user = request.user
25 | if form.is_valid():
26 | tag = form.save()
27 | return redirect('dashboard')
28 | else:
29 | form = TagForm()
30 | return render(request, 'tasks/add_tag.html', {'form': form})
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction to Django
2 |
3 | Objectives:
4 | - Introduce Django from the absolute basics.
5 | - Create a real SaaS product - ToDo website where users can register and log their tasks
6 | - Deploy on heroku
7 |
8 | To discuss any doubts or questions after today's class with the community, join Scaler Club: https://chat.scaler.com/signup_user_complete/?id=c9os5g9kobr4jqmtgadgkbgafa
9 |
10 | Prerequisites:
11 | [[Introduction to Python Series - Notes and Videos]](https://github.com/scaleracademy/intro-to-python)
12 |
13 | # Lectures
14 | - Lecture 1: [[Notes]](/lecture_1.md) [[Video]](https://www.youtube.com/watch?v=_35uYwlxcu4) [[Code]](/lecture_1/)
15 | - Lecture 2: [[Video]](https://www.youtube.com/watch?v=NYRxFU4zZNQ) [[Code]](/lecture_2/)
16 | - Lecture 3: [[Video]](https://www.youtube.com/watch?v=aavReR8gZYE) [[Code]](/lecture_3/)
17 | - Lecture 4: [[Video]](https://www.youtube.com/watch?v=GN5yvf07wCU) [[Code]](/lecture_4/)
18 | - Lecture 5: [[Video]](https://www.youtube.com/watch?v=NKOlBvSd9DQ) [[Code]](/lecture_5/)
19 | - Lecture 6: [[Video]](https://www.youtube.com/watch?v=PipHGgdR4Zg) [[Code]](/lecture_6/)
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 | from django.utils import timezone
5 |
6 |
7 | class TaskStatus(models.TextChoices):
8 | PENDING = 'PE', 'Pending'
9 | COMPLETED = 'CO', 'Completed'
10 | DROPPED = 'DR', 'Dropped'
11 |
12 |
13 | class Tag(models.Model):
14 | name = models.CharField(max_length=255)
15 |
16 | def __str__(self):
17 | return self.name
18 |
19 |
20 | class Task(models.Model):
21 | content = models.TextField()
22 | created_at = models.DateTimeField(
23 | default=timezone.now
24 | )
25 | completed_at = models.DateTimeField(null=True)
26 | deadline = models.DateTimeField(null=True, blank=True)
27 |
28 | status = models.CharField(
29 | max_length=2,
30 | choices=TaskStatus.choices,
31 | default=TaskStatus.PENDING
32 | )
33 | tags = models.ManyToManyField(Tag, blank=True)
34 |
35 | def __str__(self):
36 | return f'{self.content}'
37 |
38 | def get_all_tags(self, delimiter=', '):
39 | return delimiter.join([tag.name for tag in self.tags.all()])
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/migrations/0003_auto_20200919_1349.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.1 on 2020-09-19 13:49
2 |
3 | import datetime
4 | from django.db import migrations, models
5 | from django.utils.timezone import utc
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('tasks', '0002_auto_20200919_1330'),
12 | ]
13 |
14 | operations = [
15 | migrations.AddField(
16 | model_name='task',
17 | name='completed_at',
18 | field=models.DateTimeField(null=True),
19 | ),
20 | migrations.AlterField(
21 | model_name='task',
22 | name='created_at',
23 | field=models.DateTimeField(default=datetime.datetime(2020, 9, 19, 13, 49, 33, 56381, tzinfo=utc)),
24 | ),
25 | migrations.AlterField(
26 | model_name='task',
27 | name='deadline',
28 | field=models.DateTimeField(blank=True, null=True),
29 | ),
30 | migrations.AlterField(
31 | model_name='task',
32 | name='tags',
33 | field=models.ManyToManyField(blank=True, null=True, to='tasks.Tag'),
34 | ),
35 | ]
36 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.1 on 2020-09-19 13:10
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Tag',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('name', models.CharField(max_length=255)),
19 | ],
20 | ),
21 | migrations.CreateModel(
22 | name='Task',
23 | fields=[
24 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
25 | ('content', models.TextField()),
26 | ('created_at', models.DateTimeField()),
27 | ('deadline', models.DateTimeField()),
28 | ('status', models.CharField(choices=[('PE', 'Pending'), ('CO', 'Completed'), ('DR', 'Dropped')], default='PE', max_length=2)),
29 | ('tags', models.ManyToManyField(to='tasks.Tag')),
30 | ],
31 | ),
32 | ]
33 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/.idea/firstapp.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | from django.utils import timezone
4 | from django.contrib.auth.models import User
5 |
6 |
7 | class TaskStatus(models.TextChoices):
8 | PENDING = 'PE', 'Pending'
9 | COMPLETED = 'CO', 'Completed'
10 | DROPPED = 'DR', 'Dropped'
11 |
12 |
13 | class Tag(models.Model):
14 | user = models.ForeignKey(User, on_delete=models.CASCADE)
15 | name = models.CharField(max_length=255)
16 |
17 | def __str__(self):
18 | return self.name
19 |
20 |
21 | class Task(models.Model):
22 | user = models.ForeignKey(User, on_delete=models.CASCADE)
23 | content = models.TextField()
24 | created_at = models.DateTimeField(
25 | default=timezone.now
26 | )
27 | completed_at = models.DateTimeField(null=True)
28 | deadline = models.DateTimeField(null=True, blank=True)
29 |
30 | status = models.CharField(
31 | max_length=2,
32 | choices=TaskStatus.choices,
33 | default=TaskStatus.PENDING
34 | )
35 | tags = models.ManyToManyField(Tag, blank=True)
36 |
37 | def __str__(self):
38 | return f'{self.content}'
39 |
40 | def get_all_tags(self, delimiter=', '):
41 | return delimiter.join([tag.name for tag in self.tags.all()])
42 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.1 on 2020-09-18 13:55
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Tag',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('name', models.CharField(max_length=255)),
19 | ],
20 | ),
21 | migrations.CreateModel(
22 | name='Task',
23 | fields=[
24 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
25 | ('content', models.TextField()),
26 | ('deadline', models.DateTimeField()),
27 | ('created_at', models.DateTimeField()),
28 | ('completed_at', models.DateTimeField()),
29 | ('status', models.CharField(choices=[('CO', 'Completed'), ('PE', 'Pending'), ('DR', 'Dropped')], default='PE', max_length=2)),
30 | ('tags', models.ManyToManyField(to='tasks.Tag')),
31 | ],
32 | ),
33 | ]
34 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.utils import timezone
3 |
4 | from . import models
5 |
6 |
7 | def mark_complete(model_admin, request, queryset):
8 | queryset.update(
9 | status=models.TaskStatus.COMPLETED,
10 | completed_at=timezone.now(),
11 | )
12 |
13 |
14 | def mark_pending(model_admin, request, queryset):
15 | queryset.update(
16 | status=models.TaskStatus.PENDING,
17 | completed_at=None,
18 | )
19 |
20 |
21 | mark_complete.short_description = 'Mark these tasks as completed right now.'
22 | mark_pending.short_description = 'Mark these tasks as pending.'
23 |
24 |
25 | class TaskAdmin(admin.ModelAdmin):
26 | fields = [
27 | 'content',
28 | 'deadline',
29 | 'tags'
30 | ]
31 | list_display = ['content', 'status', 'deadline', 'get_all_tags']
32 | list_editable = ['status']
33 | actions = [mark_complete, mark_pending]
34 | list_filter = ['status', 'deadline', 'tags']
35 | search_fields = ['content', 'tags__name']
36 |
37 | ordering = ['status', 'deadline']
38 |
39 |
40 | class TagAdmin(admin.ModelAdmin):
41 | list_display = ['name']
42 | list_filter = ['name']
43 | search_fields = ['name']
44 |
45 |
46 | admin.site.register(models.Task, TaskAdmin)
47 | admin.site.register(models.Tag, TagAdmin)
48 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.utils import timezone
3 |
4 | from . import models
5 |
6 |
7 | # Register your models here.
8 |
9 | def mark_complete(model_admin, request, queryset):
10 | queryset.update(
11 | status=models.TaskStatus.COMPLETED,
12 | completed_at=timezone.now(),
13 | )
14 |
15 |
16 | def mark_pending(model_admin, request, queryset):
17 | queryset.update(
18 | status=models.TaskStatus.PENDING,
19 | completed_at=None,
20 | )
21 |
22 |
23 | mark_complete.short_description = 'Mark these tasks as completed right now.'
24 | mark_pending.short_description = 'Mark these tasks as pending.'
25 |
26 |
27 | class TaskAdmin(admin.ModelAdmin):
28 | fields = [
29 | 'content',
30 | 'deadline',
31 | 'tags'
32 | ]
33 | list_display = ['content', 'status', 'deadline', 'get_all_tags']
34 | list_editable = ['status']
35 | actions = [mark_complete, mark_pending]
36 | list_filter = ['status', 'deadline', 'tags']
37 | search_fields = ['content', 'tags__name']
38 |
39 | ordering = ['status', 'deadline']
40 |
41 |
42 | class TagAdmin(admin.ModelAdmin):
43 | list_display = ['name']
44 | list_filter = ['name']
45 | search_fields = ['name']
46 |
47 |
48 | admin.site.register(models.Task, TaskAdmin)
49 | admin.site.register(models.Tag, TagAdmin)
50 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.utils import timezone
3 |
4 | from . import models
5 | # Register your models here.
6 |
7 | def mark_complete(model_admin, request, queryset):
8 | queryset.update(
9 | status=models.TaskStatus.COMPLETED,
10 | completed_at=timezone.now(),
11 | )
12 | mark_complete.short_description = 'Mark these tasks as completed right now.'
13 |
14 |
15 | def mark_pending(model_admin, request, queryset):
16 | queryset.update(
17 | status=models.TaskStatus.PENDING,
18 | completed_at=None,
19 | )
20 | mark_pending.short_description = 'Mark these tasks as pending.'
21 |
22 | class TaskAdmin(admin.ModelAdmin):
23 | fields = [
24 | ('content', 'deadline'),
25 | 'tags'
26 | ]
27 |
28 | list_display = ['content', 'status', 'deadline'] # this allows me to render additional attributes
29 | list_editable = ['status']
30 | actions = [mark_complete, mark_pending]
31 | list_filter = ['status', 'deadline', 'tags']
32 | search_fields = ['content', 'tags__name']
33 | # ordering = ['status']
34 |
35 | def get_ordering(self, request):
36 | if request.user.is_superuser:
37 | return ['status']
38 | else:
39 | return ['deadline']
40 |
41 |
42 | admin.site.register(models.Task, TaskAdmin)
43 | admin.site.register(models.Tag)
44 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.1 on 2020-09-23 11:39
2 |
3 | from django.db import migrations, models
4 | import django.utils.timezone
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | initial = True
10 |
11 | dependencies = [
12 | ]
13 |
14 | operations = [
15 | migrations.CreateModel(
16 | name='Tag',
17 | fields=[
18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 | ('name', models.CharField(max_length=255)),
20 | ],
21 | ),
22 | migrations.CreateModel(
23 | name='Task',
24 | fields=[
25 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
26 | ('content', models.TextField()),
27 | ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
28 | ('completed_at', models.DateTimeField(null=True)),
29 | ('deadline', models.DateTimeField(blank=True, null=True)),
30 | ('status', models.CharField(choices=[('PE', 'Pending'), ('CO', 'Completed'), ('DR', 'Dropped')], default='PE', max_length=2)),
31 | ('tags', models.ManyToManyField(blank=True, to='tasks.Tag')),
32 | ],
33 | ),
34 | ]
35 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/accounts/views.py:
--------------------------------------------------------------------------------
1 | from django.contrib import messages
2 | from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout
3 | from django.shortcuts import render, redirect
4 | from django.contrib.auth.models import User
5 | from .forms import CreateUserForm
6 | # Create your views here.
7 |
8 |
9 | def login(request):
10 | if request.user.is_authenticated:
11 | return redirect('dashboard')
12 | if request.method == 'POST':
13 | username = request.POST['username']
14 | password = request.POST['password']
15 | user = authenticate(request, username=username, password=password)
16 | if user is not None:
17 | auth_login(request, user)
18 | return redirect('dashboard')
19 | else:
20 | messages.error(request, 'User OR password is incorrect')
21 | return render(request, 'accounts/login.html')
22 |
23 |
24 | def register(request):
25 | if request.user.is_authenticated:
26 | return redirect('dashboard')
27 | if request.method == 'POST':
28 | form = CreateUserForm(request.POST)
29 | if form.is_valid():
30 | user = form.save()
31 | return redirect('login')
32 | else:
33 | form = CreateUserForm()
34 | return render(request, 'accounts/register.html', {'form': form})
35 |
36 |
37 | def logout(request):
38 | auth_logout(request)
39 | return redirect('login')
40 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/tasks/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.utils import timezone
3 |
4 |
5 | class TaskStatus(models.TextChoices):
6 | PENDING = 'PE', 'Pending'
7 | COMPLETED = 'CO', 'Completed'
8 | DROPPED = 'DR', 'Dropped'
9 |
10 |
11 | class Tag(models.Model):
12 | name = models.CharField(max_length=255)
13 |
14 | # magic methods
15 | # dunder => double underscore method in python
16 |
17 | def __str__(self):
18 | # object.toString() in the java world
19 | # gives a human readable representation of the object
20 | return self.name
21 |
22 | class Task(models.Model):
23 | content = models.TextField()
24 | created_at = models.DateTimeField(
25 | default=timezone.now()
26 | )
27 | completed_at = models.DateTimeField(null=True)
28 | deadline = models.DateTimeField(null=True, blank=True)
29 | # null is False => NOT NULL
30 | # null => database thing - it is okay for this column to have a null val
31 | # blank => validation - it is okay if the user doesn't provide this field
32 |
33 | status = models.CharField(
34 | max_length=2,
35 | choices=TaskStatus.choices,
36 | default=TaskStatus.PENDING
37 | )
38 | tags = models.ManyToManyField(Tag, null=True, blank=True)
39 |
40 | @property # properties and descriptor protocol in Python
41 | def foo(self):
42 | return 'hello'
43 |
44 | def __str__(self):
45 | return f'{self.content}'
46 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/tasks/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.1.1 on 2020-09-25 13:49
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 | import django.utils.timezone
7 |
8 |
9 | class Migration(migrations.Migration):
10 |
11 | initial = True
12 |
13 | dependencies = [
14 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15 | ]
16 |
17 | operations = [
18 | migrations.CreateModel(
19 | name='Tag',
20 | fields=[
21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22 | ('name', models.CharField(max_length=255)),
23 | ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
24 | ],
25 | ),
26 | migrations.CreateModel(
27 | name='Task',
28 | fields=[
29 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
30 | ('content', models.TextField()),
31 | ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
32 | ('completed_at', models.DateTimeField(null=True)),
33 | ('deadline', models.DateTimeField(blank=True, null=True)),
34 | ('status', models.CharField(choices=[('PE', 'Pending'), ('CO', 'Completed'), ('DR', 'Dropped')], default='PE', max_length=2)),
35 | ('tags', models.ManyToManyField(blank=True, to='tasks.Tag')),
36 | ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
37 | ],
38 | ),
39 | ]
40 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/tasks/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render, redirect
2 |
3 | # Create your views here.
4 | from .forms import ContactForm, TaskForm
5 | from .models import Task
6 |
7 |
8 | # Cross Site Request Forgery
9 | # csrf_token
10 | # www.facebook.com/logout
11 | # www.facebook.com/create-message <- post
12 |
13 |
14 | def index(request):
15 | tasks = Task.objects.all()
16 | return render(request, 'tasks/index.html', {'tasks': tasks})
17 |
18 |
19 | def add_task(request):
20 | if request.method == 'POST':
21 | content = request.POST['content']
22 | deadline = request.POST['deadline']
23 | task = Task(content=content, deadline=deadline)
24 | task.save()
25 | return redirect('tasks')
26 | else:
27 | return render(request, 'tasks/new_task.html')
28 |
29 | def add_task_2(request):
30 | if request.method == 'POST':
31 | form = TaskForm(data=request.POST)
32 | if form.is_valid():
33 | new_task = form.save()
34 | return redirect('tasks')
35 | else:
36 | form = TaskForm()
37 | return render(request, 'tasks/new_task_2.html', {'form': form})
38 |
39 |
40 | def contact(request):
41 | if request.method == 'POST':
42 | subject = request.POST['subject']
43 | message = request.POST['message']
44 | email = request.POST['email']
45 | # send the email
46 | return redirect('tasks')
47 | else:
48 | return render(request, 'tasks/contact_us.html')
49 |
50 |
51 | def contact_2(request):
52 | if request.method == 'POST':
53 | form = ContactForm(data=request.POST)
54 | if form.is_valid():
55 | # send email
56 | return redirect('tasks')
57 | else:
58 | form = ContactForm()
59 | return render(request, 'tasks/contact_us_2.html', {'form': form})
60 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/tasks/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
5 | # ORM - Object Relational Mapper
6 | # takes your python objects, and stores them as database tables and rows
7 | # Models for tables
8 |
9 |
10 | # Low Level Design
11 | # Requirements
12 | # - [User] can add [Task]s
13 | # - a task can be tagged with one or more [Tag]s
14 | # - you can search for tasks by content, or by a tag
15 | # - tasks can have an urgency and an importance
16 | # - tasks can have a status - Pending, Completed, Dropped
17 |
18 | # Detect nouns -> usually become entites/models
19 | # Detect attributes and relationships
20 |
21 | # model, view, controller are decoupled
22 |
23 | # Django provides an id field to all model class by default
24 | # makes the id field an integer, which autoincrements and is the primary key
25 | # you can override
26 | class Tag(models.Model):
27 | name = models.CharField(max_length=255)
28 |
29 | # Create an rich API for us for free
30 |
31 | class Task(models.Model): # class => table
32 | content = models.TextField() # field => column in the table
33 | deadline = models.DateTimeField()
34 | created_at = models.DateTimeField()
35 | completed_at = models.DateTimeField()
36 | tags = models.ManyToManyField(Tag)
37 |
38 | class TaskStatus(models.TextChoices): # enumeration
39 | COMPLETED = "CO", "Completed"
40 | PENDING = "PE", "Pending"
41 | DROPPED = "DR", "Dropped"
42 | status = models.CharField(
43 | choices=TaskStatus.choices,
44 | default=TaskStatus.PENDING,
45 | max_length=2,
46 | ) # must have restricted set of choices
47 |
48 | # whenever I change my DB schema
49 | # - my old DB is now useless
50 | # - create a new DB?
51 | # - somehow reenter the data in the new DB => hefty task
52 | # - I don't want the users to renter the data
53 | # Migration - Migrate the previous data to new DB
54 | # approach 1 - delete DB, create new DB, enter data myself
55 | # approach 2 - write a Migration script that looks at the prev DB,
56 | # and copies the data to the new DB
57 | # Whenever I change my schema, I have to write this script again and again
58 | # I have the previous DB schema
59 | # I have the current models in Django
60 | # Can I write a script that automatically find the differences and writes the migration
61 | # script for me?
62 | # django provides this out of the box
63 |
64 |
65 |
66 | # 1 task can have 1 or more tags
67 | # 1 tag (like shopping) can also have multiple tasks
68 | # Many to Many Relationship
69 |
70 | # Task_Tags =>
71 | # id | task_id (foreign key to tasks_task.id) | tag_id
72 | # ( )
73 |
74 | # OneToOne Relationship => column in your tables
75 | # OneToMany Relationship => column in your tables
76 | # ManyToOne Relationship => column in your tables
77 | # ManyToMany Relationship => create a new table for this
78 |
--------------------------------------------------------------------------------
/lecture_2/todo_project/todo_project/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for todo_project project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '+yxzn+0hrn3kzqac869-t^4fl&*3f#4vwip$cqxvj70t!w8s6+'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'django.contrib.admin',
35 | 'django.contrib.auth',
36 | 'django.contrib.contenttypes',
37 | 'django.contrib.sessions',
38 | 'django.contrib.messages',
39 | 'django.contrib.staticfiles',
40 | ]
41 |
42 | MIDDLEWARE = [
43 | 'django.middleware.security.SecurityMiddleware',
44 | 'django.contrib.sessions.middleware.SessionMiddleware',
45 | 'django.middleware.common.CommonMiddleware',
46 | 'django.middleware.csrf.CsrfViewMiddleware',
47 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
48 | 'django.contrib.messages.middleware.MessageMiddleware',
49 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50 | ]
51 |
52 | ROOT_URLCONF = 'todo_project.urls'
53 |
54 | TEMPLATES = [
55 | {
56 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
57 | 'DIRS': [BASE_DIR / 'templates'],
58 | 'APP_DIRS': True,
59 | 'OPTIONS': {
60 | 'context_processors': [
61 | 'django.template.context_processors.debug',
62 | 'django.template.context_processors.request',
63 | 'django.contrib.auth.context_processors.auth',
64 | 'django.contrib.messages.context_processors.messages',
65 | ],
66 | },
67 | },
68 | ]
69 |
70 | WSGI_APPLICATION = 'todo_project.wsgi.application'
71 |
72 |
73 | # Database
74 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
75 |
76 | DATABASES = {
77 | 'default': {
78 | 'ENGINE': 'django.db.backends.sqlite3',
79 | 'NAME': BASE_DIR / 'db.sqlite3',
80 | }
81 | }
82 |
83 |
84 | # Password validation
85 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
86 |
87 | AUTH_PASSWORD_VALIDATORS = [
88 | {
89 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
90 | },
91 | {
92 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
93 | },
94 | {
95 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
96 | },
97 | {
98 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
99 | },
100 | ]
101 |
102 |
103 | # Internationalization
104 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
105 |
106 | LANGUAGE_CODE = 'en-us'
107 |
108 | TIME_ZONE = 'UTC'
109 |
110 | USE_I18N = True
111 |
112 | USE_L10N = True
113 |
114 | USE_TZ = True
115 |
116 |
117 | # Static files (CSS, JavaScript, Images)
118 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
119 |
120 | STATIC_URL = '/static/'
121 |
--------------------------------------------------------------------------------
/lecture_1/firstapp/firstapp/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for firstapp project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '&$o9u99_1x8d96fn(&17fr*7_fu(6@pb9wdg3=m&7fxg8v2%r*'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = False
27 |
28 | ALLOWED_HOSTS = ['localhost']
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'django.contrib.admin',
35 | 'django.contrib.auth',
36 | 'django.contrib.contenttypes',
37 | 'django.contrib.sessions',
38 | 'django.contrib.messages',
39 | 'django.contrib.staticfiles',
40 | ]
41 |
42 | MIDDLEWARE = [
43 | 'django.middleware.security.SecurityMiddleware',
44 | 'django.contrib.sessions.middleware.SessionMiddleware',
45 | 'django.middleware.common.CommonMiddleware',
46 | 'django.middleware.csrf.CsrfViewMiddleware',
47 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
48 | 'django.contrib.messages.middleware.MessageMiddleware',
49 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50 | ]
51 |
52 | ROOT_URLCONF = 'firstapp.urls'
53 |
54 | TEMPLATES = [
55 | {
56 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
57 | 'DIRS': [BASE_DIR / 'templates']
58 | ,
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'firstapp.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': BASE_DIR / 'db.sqlite3',
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_L10N = True
114 |
115 | USE_TZ = True
116 |
117 |
118 | # Static files (CSS, JavaScript, Images)
119 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
120 |
121 | STATIC_URL = '/static/'
122 |
--------------------------------------------------------------------------------
/lecture_4/todo_project_4/todo_project_4/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for todo_project_4 project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 'p#tp%@rwbqex1b^p4u1(dzje(o=o(hl^@tw30(nqc9@4oxo6hp'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'tasks.apps.TasksConfig',
35 | 'django.contrib.admin',
36 | 'django.contrib.auth',
37 | 'django.contrib.contenttypes',
38 | 'django.contrib.sessions',
39 | 'django.contrib.messages',
40 | 'django.contrib.staticfiles',
41 | ]
42 |
43 | MIDDLEWARE = [
44 | 'django.middleware.security.SecurityMiddleware',
45 | 'django.contrib.sessions.middleware.SessionMiddleware',
46 | 'django.middleware.common.CommonMiddleware',
47 | 'django.middleware.csrf.CsrfViewMiddleware',
48 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | ]
52 |
53 | ROOT_URLCONF = 'todo_project_4.urls'
54 |
55 | TEMPLATES = [
56 | {
57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58 | 'DIRS': [],
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'todo_project_4.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': BASE_DIR / 'db.sqlite3',
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_L10N = True
114 |
115 | USE_TZ = True
116 |
117 |
118 | # Static files (CSS, JavaScript, Images)
119 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
120 |
121 | STATIC_URL = '/static/'
122 |
--------------------------------------------------------------------------------
/lecture_3/todo_project_2/todo_project_day_2/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for todo_project_day_2 project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '4-!d&k*1cv+g%9yn13j1c1u(b+yaekye6vjbia3kwu6v-j-vor'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'tasks.apps.TasksConfig',
35 | 'django.contrib.admin',
36 | 'django.contrib.auth',
37 | 'django.contrib.contenttypes',
38 | 'django.contrib.sessions',
39 | 'django.contrib.messages',
40 | 'django.contrib.staticfiles',
41 | ]
42 |
43 | MIDDLEWARE = [
44 | 'django.middleware.security.SecurityMiddleware',
45 | 'django.contrib.sessions.middleware.SessionMiddleware',
46 | 'django.middleware.common.CommonMiddleware',
47 | 'django.middleware.csrf.CsrfViewMiddleware',
48 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | ]
52 |
53 | ROOT_URLCONF = 'todo_project_day_2.urls'
54 |
55 | TEMPLATES = [
56 | {
57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58 | 'DIRS': [],
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'todo_project_day_2.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': BASE_DIR / 'db.sqlite3',
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_L10N = True
114 |
115 | USE_TZ = True
116 |
117 |
118 | # Static files (CSS, JavaScript, Images)
119 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
120 |
121 | STATIC_URL = '/static/'
122 |
--------------------------------------------------------------------------------
/lecture_5/todo_project_5/todo_project_5/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for todo_project_5 project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '4s%*pskjg0_ib-=#(^7=z)0mvw#z8teoib7kvey*u@1!e_#j$*'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'tasks.apps.TasksConfig',
35 | 'django.contrib.admin',
36 | 'django.contrib.auth',
37 | 'django.contrib.contenttypes',
38 | 'django.contrib.sessions',
39 | 'django.contrib.messages',
40 | 'django.contrib.staticfiles',
41 | ]
42 |
43 | MIDDLEWARE = [
44 | 'django.middleware.security.SecurityMiddleware',
45 | 'django.contrib.sessions.middleware.SessionMiddleware',
46 | 'django.middleware.common.CommonMiddleware',
47 | 'django.middleware.csrf.CsrfViewMiddleware',
48 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | ]
52 |
53 | ROOT_URLCONF = 'todo_project_5.urls'
54 |
55 | TEMPLATES = [
56 | {
57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58 | 'DIRS': [BASE_DIR / 'templates'],
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'todo_project_5.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': BASE_DIR / 'db.sqlite3',
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_L10N = True
114 |
115 | USE_TZ = True
116 |
117 |
118 | # Static files (CSS, JavaScript, Images)
119 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
120 |
121 | STATIC_URL = '/static/'
122 |
--------------------------------------------------------------------------------
/lecture_6/todo_project_6/todo_project_6/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for todo_project_6 project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.1.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 't!de3_++i592r&w9ke#32!3e%&s0g#z1lkh0(kag-s=97zm5b&'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'accounts.apps.AccountsConfig',
35 | 'tasks.apps.TasksConfig',
36 | 'pages.apps.PagesConfig',
37 | 'django.contrib.admin',
38 | 'django.contrib.auth',
39 | 'django.contrib.contenttypes',
40 | 'django.contrib.sessions',
41 | 'django.contrib.messages',
42 | 'django.contrib.staticfiles',
43 | ]
44 |
45 | MIDDLEWARE = [
46 | 'django.middleware.security.SecurityMiddleware',
47 | 'django.contrib.sessions.middleware.SessionMiddleware',
48 | 'django.middleware.common.CommonMiddleware',
49 | 'django.middleware.csrf.CsrfViewMiddleware',
50 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
51 | 'django.contrib.messages.middleware.MessageMiddleware',
52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
53 | ]
54 |
55 | ROOT_URLCONF = 'todo_project_6.urls'
56 |
57 | TEMPLATES = [
58 | {
59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
60 | 'DIRS': [BASE_DIR / 'templates'],
61 | 'APP_DIRS': True,
62 | 'OPTIONS': {
63 | 'context_processors': [
64 | 'django.template.context_processors.debug',
65 | 'django.template.context_processors.request',
66 | 'django.contrib.auth.context_processors.auth',
67 | 'django.contrib.messages.context_processors.messages',
68 | ],
69 | },
70 | },
71 | ]
72 |
73 | WSGI_APPLICATION = 'todo_project_6.wsgi.application'
74 |
75 |
76 | # Database
77 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
78 |
79 | DATABASES = {
80 | 'default': {
81 | 'ENGINE': 'django.db.backends.sqlite3',
82 | 'NAME': BASE_DIR / 'db.sqlite3',
83 | }
84 | }
85 |
86 |
87 | # Password validation
88 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
89 |
90 | AUTH_PASSWORD_VALIDATORS = [
91 | {
92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
93 | },
94 | {
95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
96 | },
97 | {
98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
99 | },
100 | {
101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
102 | },
103 | ]
104 |
105 |
106 | # Internationalization
107 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
108 |
109 | LANGUAGE_CODE = 'en-us'
110 |
111 | TIME_ZONE = 'UTC'
112 |
113 | USE_I18N = True
114 |
115 | USE_L10N = True
116 |
117 | USE_TZ = True
118 |
119 |
120 | # Static files (CSS, JavaScript, Images)
121 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
122 |
123 | STATIC_URL = '/static/'
124 |
--------------------------------------------------------------------------------