├── .gitignore ├── LICENSE.md ├── README.md ├── manage.py ├── requirements.txt ├── season1 ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py └── sunflower ├── __init__.py ├── admin.py ├── apps.py ├── migrations ├── 0001_initial.py ├── 0002_auto_20170419_0050.py └── __init__.py ├── models.py ├── templates └── sunflower │ ├── base.html │ ├── flower_form.html │ ├── flower_list.html │ ├── garden_form.html │ └── index.html ├── tests.py └── views.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | db.sqlite3 3 | .idea/ -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Md. Sabuj Sarker | https://sabuj.me | md.sabuj.sarker@gmail.com | https://www.youtube.com/c/MdSabujSarker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Django Webinar In Bangla: Season 1 2 | I am doing a live webinar with live question answer on youtube through hangout. Channel address: [Md Sabuj Sarker on Youtube](https://www.youtube.com/c/MdSabujSarker) 3 | 4 | 5 | All the codes during the webinar will be pushed to this repository. 6 | 7 | 8 | # On Request I will do this in English too. 9 | I have started doing it in Bangla (my native language) because most of the people in my [Python community: The Pythonic](http://thepythonic.lozish.com) speaks Bangla. If I get more interested people who do not speak Bangla then I would also like to do this in English. 10 | 11 | 12 | Connect me on facebook: [Sabuj Sarker on Facebook](https://www.facebook.com/SabujXi) and [Sabuj Sarker Page on Facebook](https://www.facebook.com/SabujXiP) 13 | 14 | Connect me on Linkedin: [Sabuj Sarker on Linkedin](https://www.linkedin.com/in/sabujxi/) 15 | 16 | Connect me on Twitter: [Sabuj Sarker on Twitter](https://twitter.com/SabujXi) 17 | 18 | Connect me on my Blog: [sabuj.me](https://sabuj.me) 19 | 20 | Connect me on Lozish Labs: [Lozish.com](http://lozish.com) 21 | 22 | 23 | # Episode Links 24 | 25 | 0) [Episode 00](https://www.youtube.com/watch?v=OccxaCPw2sY) 26 | 1) [Episode 01](https://www.youtube.com/watch?v=G_M-oALIUc4) 27 | 2) [Episode 02](https://www.youtube.com/watch?v=FsB2op3ZVt0) 28 | 3) [Episode 03](https://www.youtube.com/watch?v=a_Zh0pTClqY) 29 | 30 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "season1.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | appdirs==1.4.3 2 | Django==1.11 3 | packaging==16.8 4 | pyparsing==2.2.0 5 | pytz==2017.2 6 | six==1.10.0 7 | -------------------------------------------------------------------------------- /season1/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SabujXi/Python-Django-Webinar-In-Bangla-Season-1/7f302baac20cd7807ae41fb3dab8a590d15f387b/season1/__init__.py -------------------------------------------------------------------------------- /season1/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for season1 project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.11. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.11/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'q$-gpymh^=7f7nvv*)&(d0+u@^4#x&t((3ogqgc!^bw4fs#38h' 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 | 'sunflower' 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 = 'season1.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 = 'season1.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/1.11/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/1.11/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/1.11/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/1.11/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /season1/urls.py: -------------------------------------------------------------------------------- 1 | """season1 URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.11/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: url(r'^$', 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: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url 17 | from django.contrib import admin 18 | 19 | from sunflower.views import hi, index, flower_crud, garden_crud, list_flowers 20 | 21 | urlpatterns = [ 22 | #url(r'^admin/', admin.site.urls), 23 | url(r'^$', index), 24 | url(r'^hi/', hi), 25 | url(r'^f_crud', flower_crud), 26 | url(r'^g_crud', garden_crud), 27 | url(r'^lf', list_flowers) 28 | ] 29 | -------------------------------------------------------------------------------- /season1/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for season1 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/1.11/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", "season1.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /sunflower/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SabujXi/Python-Django-Webinar-In-Bangla-Season-1/7f302baac20cd7807ae41fb3dab8a590d15f387b/sunflower/__init__.py -------------------------------------------------------------------------------- /sunflower/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /sunflower/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SunflowerConfig(AppConfig): 5 | name = 'sunflower' 6 | -------------------------------------------------------------------------------- /sunflower/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11 on 2017-04-18 18:38 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | initial = True 12 | 13 | dependencies = [ 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Flower', 19 | fields=[ 20 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('name', models.CharField(max_length=128, unique=True)), 22 | ('color', models.CharField(max_length=64)), 23 | ('description', models.TextField(default='')), 24 | ], 25 | ), 26 | migrations.CreateModel( 27 | name='Garden', 28 | fields=[ 29 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 30 | ('name', models.CharField(max_length=128, unique=True)), 31 | ('description', models.TextField(default='')), 32 | ], 33 | ), 34 | migrations.AddField( 35 | model_name='flower', 36 | name='garden', 37 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sunflower.Garden'), 38 | ), 39 | ] 40 | -------------------------------------------------------------------------------- /sunflower/migrations/0002_auto_20170419_0050.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11 on 2017-04-18 18:50 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | 8 | 9 | class Migration(migrations.Migration): 10 | 11 | dependencies = [ 12 | ('sunflower', '0001_initial'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AlterField( 17 | model_name='flower', 18 | name='garden', 19 | field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='sunflower.Garden'), 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /sunflower/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SabujXi/Python-Django-Webinar-In-Bangla-Season-1/7f302baac20cd7807ae41fb3dab8a590d15f387b/sunflower/migrations/__init__.py -------------------------------------------------------------------------------- /sunflower/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | 5 | 6 | class Garden(models.Model): 7 | name = models.CharField(max_length=128, unique=True) 8 | description = models.TextField(default="") 9 | 10 | 11 | class Flower(models.Model): 12 | name = models.CharField(max_length=128, unique=True) 13 | color = models.CharField(max_length=64) 14 | description = models.TextField(default="") 15 | garden = models.ForeignKey(Garden, null=True, default=None, on_delete=models.CASCADE) 16 | -------------------------------------------------------------------------------- /sunflower/templates/sunflower/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {% block title %} {% endblock title %} 6 | 7 | 8 | {% block content %} 9 | 10 | {% endblock %} 11 | 12 | -------------------------------------------------------------------------------- /sunflower/templates/sunflower/flower_form.html: -------------------------------------------------------------------------------- 1 | {% extends "./base.html" %} 2 | 3 | {% block title %} Give me some flower {% endblock title %} 4 | 5 | {% block content %} 6 |
7 | {% csrf_token %} 8 | Flower Name:
9 | Flower Color:
10 | Description:
11 | Which Garden? : 16 |
17 | 18 |
19 | {% endblock content %} -------------------------------------------------------------------------------- /sunflower/templates/sunflower/flower_list.html: -------------------------------------------------------------------------------- 1 | {% extends "./base.html" %} 2 | 3 | {% block title %} Give me ak botol flower {% endblock title %} 4 | 5 | {% block content %} 6 | 7 | 8 | 9 | 10 | 11 | {% for f in flowers %} 12 | 13 | 14 | 15 | 16 | {% endfor %} 17 |
NameColor
{{ f.name }} {{ f.color }}
18 | {% endblock content %} -------------------------------------------------------------------------------- /sunflower/templates/sunflower/garden_form.html: -------------------------------------------------------------------------------- 1 | {% extends "./base.html" %} 2 | 3 | {% block title %} Garden Entry {% endblock title %} 4 | 5 | {% block content %} 6 |
7 | {% csrf_token %} 8 | Garden Name:
9 | Description:
10 | 11 |
12 | {% endblock content %} -------------------------------------------------------------------------------- /sunflower/templates/sunflower/index.html: -------------------------------------------------------------------------------- 1 | {% extends "./base.html" %} 2 | 3 | {% block title %} Index Page {% endblock title %} 4 | 5 | {% block content %} 6 | Ahh, I am alive. 7 | {% endblock content %} 8 | 9 | -------------------------------------------------------------------------------- /sunflower/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /sunflower/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | from django.http import HttpResponse 4 | 5 | from sunflower.models import Flower, Garden 6 | 7 | 8 | def hi(request): 9 | return HttpResponse("You said hi I said bye") 10 | 11 | def index(r): 12 | return render(r, "sunflower/index.html") 13 | 14 | 15 | def flower_crud(request): 16 | if request.method == "GET": 17 | gardens = list(Garden.objects.all()) 18 | context = { 19 | 'gardens': gardens 20 | } 21 | return render(request, 'sunflower/flower_form.html', context) 22 | 23 | else: # assumes that the method is POST method 24 | name = request.POST.get('name', '') 25 | color = request.POST.get('color', '') 26 | description = request.POST.get('description', '') 27 | gid = request.POST.get('gid', '0') 28 | f = Flower(name=name, color=color) 29 | f.description = description 30 | f.garden = Garden.objects.get(id=int(gid)) 31 | f.save() 32 | context = { 33 | 'name': name, 34 | 'color': color, 35 | 'description': description, 36 | 'gid': gid, 37 | 'gardens': list(Garden.objects.all()) 38 | } 39 | # print(":::: name was '%s' color was '%s'" % (name, color)) 40 | return render(request, 'sunflower/flower_form.html', context=context) 41 | 42 | 43 | def garden_crud(request): 44 | if request.method == "GET": 45 | return render(request, 'sunflower/garden_form.html') 46 | else: # assumes that the method is POST method 47 | name = request.POST.get('name', '') 48 | description = request.POST.get('description', '') 49 | g = Garden(name=name) 50 | g.description = description 51 | g.save() 52 | context = { 53 | 'name': name, 54 | 'description': description 55 | } 56 | # print(":::: name was '%s' color was '%s'" % (name, color)) 57 | return render(request, 'sunflower/garden_form.html', context=context) 58 | 59 | 60 | def list_flowers(request): 61 | fl = Flower.objects.all() 62 | context = { 63 | 'flowers': fl 64 | } 65 | return render(request, 'sunflower/flower_list.html', context=context) 66 | --------------------------------------------------------------------------------