├── .gitignore ├── README.md ├── core ├── __init__.py ├── categorias │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── fixtures │ │ └── categorias.json │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_alter_categoria_id.py │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── produtos │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── fixtures │ │ └── produtos.json │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_auto_20210702_0235.py │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── settings.py ├── urls.py └── wsgi.py ├── manage.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/linux,macos,django,python 3 | 4 | ### Django ### 5 | *.log 6 | *.pot 7 | *.pyc 8 | __pycache__/ 9 | local_settings.py 10 | db.sqlite3 11 | media 12 | 13 | # If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ 14 | # in your Git repository. Update and uncomment the following line accordingly. 15 | # /staticfiles/ 16 | 17 | ### Linux ### 18 | *~ 19 | 20 | # temporary files which can be created if a process still has a handle open of a deleted file 21 | .fuse_hidden* 22 | 23 | # KDE directory preferences 24 | .directory 25 | 26 | # Linux trash folder which might appear on any partition or disk 27 | .Trash-* 28 | 29 | # .nfs files are created when an open file is removed but is still being accessed 30 | .nfs* 31 | 32 | ### macOS ### 33 | *.DS_Store 34 | .AppleDouble 35 | .LSOverride 36 | 37 | # Icon must end with two \r 38 | Icon 39 | 40 | # Thumbnails 41 | ._* 42 | 43 | # Files that might appear in the root of a volume 44 | .DocumentRevisions-V100 45 | .fseventsd 46 | .Spotlight-V100 47 | .TemporaryItems 48 | .Trashes 49 | .VolumeIcon.icns 50 | .com.apple.timemachine.donotpresent 51 | 52 | # Directories potentially created on remote AFP share 53 | .AppleDB 54 | .AppleDesktop 55 | Network Trash Folder 56 | Temporary Items 57 | .apdisk 58 | 59 | ### Python ### 60 | # Byte-compiled / optimized / DLL files 61 | *.py[cod] 62 | *$py.class 63 | 64 | # C extensions 65 | *.so 66 | 67 | # Distribution / packaging 68 | .Python 69 | env/ 70 | build/ 71 | develop-eggs/ 72 | dist/ 73 | downloads/ 74 | eggs/ 75 | .eggs/ 76 | lib/ 77 | lib64/ 78 | parts/ 79 | sdist/ 80 | var/ 81 | wheels/ 82 | *.egg-info/ 83 | .installed.cfg 84 | *.egg 85 | 86 | # PyInstaller 87 | # Usually these files are written by a python script from a template 88 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 89 | *.manifest 90 | *.spec 91 | 92 | # Installer logs 93 | pip-log.txt 94 | pip-delete-this-directory.txt 95 | 96 | # Unit test / coverage reports 97 | htmlcov/ 98 | .tox/ 99 | .coverage 100 | .coverage.* 101 | .cache 102 | nosetests.xml 103 | coverage.xml 104 | *,cover 105 | .hypothesis/ 106 | 107 | # Translations 108 | *.mo 109 | 110 | # Django stuff: 111 | 112 | # Flask stuff: 113 | instance/ 114 | .webassets-cache 115 | 116 | # Scrapy stuff: 117 | .scrapy 118 | 119 | # Sphinx documentation 120 | docs/_build/ 121 | 122 | # PyBuilder 123 | target/ 124 | 125 | # Jupyter Notebook 126 | .ipynb_checkpoints 127 | 128 | # pyenv 129 | .python-version 130 | 131 | # celery beat schedule file 132 | celerybeat-schedule 133 | 134 | # SageMath parsed files 135 | *.sage.py 136 | 137 | # dotenv 138 | .env 139 | 140 | # virtualenv 141 | .venv 142 | venv/ 143 | ENV/ 144 | 145 | # Spyder project settings 146 | .spyderproject 147 | .spyproject 148 | 149 | # Rope project settings 150 | .ropeproject 151 | 152 | # mkdocs documentation 153 | /site 154 | 155 | # End of https://www.gitignore.io/api/linux,macos,django,python 156 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # De SQL para ORM Django 2 | Criei esse projeto para criar os exemplos para a palestra que fiz na The Developer's Conference (TDC) 2017. 3 | 4 | ## Procedimentos 5 | ### Clone o repositório 6 | 7 | ```console 8 | git clone git@github.com:beatrizuezu/de-sql-para-orm-django.git de-sql-para-orm-django 9 | cd de-sql-para-orm-django 10 | ``` 11 | ### Crie um virtualenv com Python 3.x e ative 12 | ```console 13 | virtualenv .env -p python3 14 | source .env/bin/activate 15 | ``` 16 | ### Instale as dependencias 17 | ```console 18 | pip install -r requirements.txt 19 | ``` 20 | 21 | ### Crie um banco chamado `exemplo` no MySQL 22 | ```mysql 23 | create database exemplo; 24 | ``` 25 | 26 | ### E execute as migrations 27 | ```console 28 | ./manage.py migrate 29 | ``` 30 | 31 | ### Popular os dados no banco 32 | ```console 33 | ./manage.py loaddata categorias produtos 34 | ``` 35 | ### Rodar o shell 36 | ```console 37 | ./manage.py shell 38 | ``` 39 | 40 | ### Seguir os passos dessa [publicação](https://medium.com/@beatrizuezu/visualizando-query-sql-a-partir-do-orm-django-5771370a9c55) 41 | -------------------------------------------------------------------------------- /core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatrizuezu/de-sql-para-orm-django/389f0525b6990f328f69d2233be9715655d44149/core/__init__.py -------------------------------------------------------------------------------- /core/categorias/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatrizuezu/de-sql-para-orm-django/389f0525b6990f328f69d2233be9715655d44149/core/categorias/__init__.py -------------------------------------------------------------------------------- /core/categorias/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /core/categorias/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CategoriaConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'core.categorias' 7 | -------------------------------------------------------------------------------- /core/categorias/fixtures/categorias.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "model":"categorias.categoria", 4 | "pk":1, 5 | "fields":{ 6 | "nome":"categoria_1" 7 | } 8 | }, 9 | { 10 | "model":"categorias.categoria", 11 | "pk":2, 12 | "fields":{ 13 | "nome":"categoria_2" 14 | } 15 | }, 16 | { 17 | "model":"categorias.categoria", 18 | "pk":3, 19 | "fields":{ 20 | "nome":"categoria_3" 21 | } 22 | }, 23 | { 24 | "model":"categorias.categoria", 25 | "pk":4, 26 | "fields":{ 27 | "nome":"categoria_4" 28 | } 29 | }, 30 | { 31 | "model":"categorias.categoria", 32 | "pk":5, 33 | "fields":{ 34 | "nome":"categoria_5" 35 | } 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /core/categorias/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.3 on 2017-07-12 01:08 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='Categoria', 18 | fields=[ 19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('nome', models.CharField(max_length=128, verbose_name='Nome')), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /core/categorias/migrations/0002_alter_categoria_id.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.5 on 2021-07-02 02:35 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('categorias', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='categoria', 15 | name='id', 16 | field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /core/categorias/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatrizuezu/de-sql-para-orm-django/389f0525b6990f328f69d2233be9715655d44149/core/categorias/migrations/__init__.py -------------------------------------------------------------------------------- /core/categorias/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Categoria(models.Model): 4 | nome = models.CharField('Nome', max_length=128) 5 | 6 | def __str__(self): 7 | return '%s' % self.nome 8 | -------------------------------------------------------------------------------- /core/categorias/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /core/categorias/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /core/produtos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatrizuezu/de-sql-para-orm-django/389f0525b6990f328f69d2233be9715655d44149/core/produtos/__init__.py -------------------------------------------------------------------------------- /core/produtos/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /core/produtos/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ProdutoConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'core.produtos' 7 | -------------------------------------------------------------------------------- /core/produtos/fixtures/produtos.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "model":"produtos.produto", 4 | "pk":1, 5 | "fields":{ 6 | "nome":"Produto 1 da Categoria 1", 7 | "valor":"2.00", 8 | "categoria":1 9 | } 10 | }, 11 | { 12 | "model":"produtos.produto", 13 | "pk":2, 14 | "fields":{ 15 | "nome":"Produto 2 da Categoria 1", 16 | "valor":"5.00", 17 | "categoria":1 18 | } 19 | }, 20 | { 21 | "model":"produtos.produto", 22 | "pk":3, 23 | "fields":{ 24 | "nome":"Produto 3 da Categoria 1", 25 | "valor":"20.00", 26 | "categoria":1 27 | } 28 | }, 29 | { 30 | "model":"produtos.produto", 31 | "pk":4, 32 | "fields":{ 33 | "nome":"Produto 4 da Categoria 1", 34 | "valor":"15.00", 35 | "categoria":1 36 | } 37 | }, 38 | { 39 | "model":"produtos.produto", 40 | "pk":5, 41 | "fields":{ 42 | "nome":"Produto 5 da Categoria 1", 43 | "valor":"10.00", 44 | "categoria":1 45 | } 46 | }, 47 | { 48 | "model":"produtos.produto", 49 | "pk":6, 50 | "fields":{ 51 | "nome":"Produto 1 da Categoria 2", 52 | "valor":"5.00", 53 | "categoria":2 54 | } 55 | }, 56 | { 57 | "model":"produtos.produto", 58 | "pk":7, 59 | "fields":{ 60 | "nome":"Produto 2 da Categoria 2", 61 | "valor":"7.00", 62 | "categoria":2 63 | } 64 | }, 65 | { 66 | "model":"produtos.produto", 67 | "pk":8, 68 | "fields":{ 69 | "nome":"Produto 3 da Categoria 2", 70 | "valor":"20.00", 71 | "categoria":2 72 | } 73 | }, 74 | { 75 | "model":"produtos.produto", 76 | "pk":9, 77 | "fields":{ 78 | "nome":"Produto 4 da Categoria 2", 79 | "valor":"15.00", 80 | "categoria":2 81 | } 82 | }, 83 | { 84 | "model":"produtos.produto", 85 | "pk":10, 86 | "fields":{ 87 | "nome":"Produto 5 da Categoria 2", 88 | "valor":"19.00", 89 | "categoria":2 90 | } 91 | }, 92 | { 93 | "model":"produtos.produto", 94 | "pk":11, 95 | "fields":{ 96 | "nome":"Produto 1 da Categoria 3", 97 | "valor":"12.00", 98 | "categoria":3 99 | } 100 | }, 101 | { 102 | "model":"produtos.produto", 103 | "pk":12, 104 | "fields":{ 105 | "nome":"Produto 2 da Categoria 3", 106 | "valor":"14.00", 107 | "categoria":3 108 | } 109 | }, 110 | { 111 | "model":"produtos.produto", 112 | "pk":13, 113 | "fields":{ 114 | "nome":"Produto 3 da Categoria 3", 115 | "valor":"100.00", 116 | "categoria":3 117 | } 118 | }, 119 | { 120 | "model":"produtos.produto", 121 | "pk":14, 122 | "fields":{ 123 | "nome":"Produto 4 da Categoria 3", 124 | "valor":"10.20", 125 | "categoria":3 126 | } 127 | }, 128 | { 129 | "model":"produtos.produto", 130 | "pk":15, 131 | "fields":{ 132 | "nome":"Produto 5 da Categoria 3", 133 | "valor":"11.40", 134 | "categoria":3 135 | } 136 | }, 137 | { 138 | "model":"produtos.produto", 139 | "pk":16, 140 | "fields":{ 141 | "nome":"Produto 1 da Categoria 4", 142 | "valor":"75.05", 143 | "categoria":4 144 | } 145 | }, 146 | { 147 | "model":"produtos.produto", 148 | "pk":17, 149 | "fields":{ 150 | "nome":"Produto 2 da Categoria 4", 151 | "valor":"44.20", 152 | "categoria":4 153 | } 154 | }, 155 | { 156 | "model":"produtos.produto", 157 | "pk":18, 158 | "fields":{ 159 | "nome":"Produto 3 da Categoria 4", 160 | "valor":"22.10", 161 | "categoria":4 162 | } 163 | }, 164 | { 165 | "model":"produtos.produto", 166 | "pk":19, 167 | "fields":{ 168 | "nome":"Produto 4 da Categoria 4", 169 | "valor":"44.20", 170 | "categoria":4 171 | } 172 | }, 173 | { 174 | "model":"produtos.produto", 175 | "pk":20, 176 | "fields":{ 177 | "nome":"Produto 5 da Categoria 4", 178 | "valor":"23.75", 179 | "categoria":4 180 | } 181 | }, 182 | { 183 | "model":"produtos.produto", 184 | "pk":21, 185 | "fields":{ 186 | "nome":"Produto 1 da Categoria 5", 187 | "valor":"5.50", 188 | "categoria":5 189 | } 190 | }, 191 | { 192 | "model":"produtos.produto", 193 | "pk":22, 194 | "fields":{ 195 | "nome":"Produto 2 da Categoria 5", 196 | "valor":"17.80", 197 | "categoria":5 198 | } 199 | }, 200 | { 201 | "model":"produtos.produto", 202 | "pk":23, 203 | "fields":{ 204 | "nome":"Produto 3 da Categoria 5", 205 | "valor":"17.45", 206 | "categoria":5 207 | } 208 | }, 209 | { 210 | "model":"produtos.produto", 211 | "pk":24, 212 | "fields":{ 213 | "nome":"Produto 4 da Categoria 5", 214 | "valor":"33.45", 215 | "categoria":5 216 | } 217 | }, 218 | { 219 | "model":"produtos.produto", 220 | "pk":25, 221 | "fields":{ 222 | "nome":"Produto 5 da Categoria 5", 223 | "valor":"13.00", 224 | "categoria":5 225 | } 226 | } 227 | ] 228 | -------------------------------------------------------------------------------- /core/produtos/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.3 on 2017-08-07 16:24 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 | ('categorias', '0001_initial'), 15 | ] 16 | 17 | operations = [ 18 | migrations.CreateModel( 19 | name='Produto', 20 | fields=[ 21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 22 | ('nome', models.CharField(max_length=128, verbose_name='Nome')), 23 | ('valor', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='Valor')), 24 | ('categoria', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='categorias.Categoria')), 25 | ], 26 | ), 27 | ] 28 | -------------------------------------------------------------------------------- /core/produtos/migrations/0002_auto_20210702_0235.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.5 on 2021-07-02 02:35 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('categorias', '0002_alter_categoria_id'), 11 | ('produtos', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AlterField( 16 | model_name='produto', 17 | name='categoria', 18 | field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='categorias.categoria'), 19 | ), 20 | migrations.AlterField( 21 | model_name='produto', 22 | name='id', 23 | field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), 24 | ), 25 | ] 26 | -------------------------------------------------------------------------------- /core/produtos/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beatrizuezu/de-sql-para-orm-django/389f0525b6990f328f69d2233be9715655d44149/core/produtos/migrations/__init__.py -------------------------------------------------------------------------------- /core/produtos/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from core.categorias.models import Categoria 3 | 4 | class Produto(models.Model): 5 | nome = models.CharField( 6 | 'Nome', 7 | max_length=128 8 | ) 9 | valor = models.DecimalField( 10 | 'Valor', 11 | max_digits=10, 12 | decimal_places=2, 13 | blank=True, 14 | null=True 15 | ) 16 | categoria = models.ForeignKey(Categoria, models.SET_NULL, null=True) 17 | 18 | def __str__(self): 19 | return '%s' % self.nome 20 | -------------------------------------------------------------------------------- /core/produtos/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /core/produtos/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /core/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = 'j0xt2haoc*yc(4(80lfg_*-7!$x0jr7p(2)gdxyzeueflnl08a' 6 | 7 | DEBUG = True 8 | 9 | ALLOWED_HOSTS = [] 10 | 11 | INSTALLED_APPS = [ 12 | 'django.contrib.admin', 13 | 'django.contrib.auth', 14 | 'django.contrib.contenttypes', 15 | 'django.contrib.sessions', 16 | 'django.contrib.messages', 17 | 'django.contrib.staticfiles', 18 | 'core.categorias', 19 | 'core.produtos' 20 | ] 21 | 22 | MIDDLEWARE = [ 23 | 'django.middleware.security.SecurityMiddleware', 24 | 'django.contrib.sessions.middleware.SessionMiddleware', 25 | 'django.middleware.common.CommonMiddleware', 26 | 'django.middleware.csrf.CsrfViewMiddleware', 27 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 28 | 'django.contrib.messages.middleware.MessageMiddleware', 29 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 30 | ] 31 | 32 | ROOT_URLCONF = 'core.urls' 33 | 34 | TEMPLATES = [ 35 | { 36 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 37 | 'DIRS': [], 38 | 'APP_DIRS': True, 39 | 'OPTIONS': { 40 | 'context_processors': [ 41 | 'django.template.context_processors.debug', 42 | 'django.template.context_processors.request', 43 | 'django.contrib.auth.context_processors.auth', 44 | 'django.contrib.messages.context_processors.messages', 45 | ], 46 | }, 47 | }, 48 | ] 49 | 50 | WSGI_APPLICATION = 'core.wsgi.application' 51 | 52 | DATABASES = { 53 | 'default': { 54 | 'ENGINE': 'django.db.backends.mysql', 55 | 'NAME': 'exemplo', 56 | 'USER': 'root', 57 | 'PASSWORD': 'root' 58 | } 59 | } 60 | 61 | AUTH_PASSWORD_VALIDATORS = [ 62 | { 63 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 64 | }, 65 | { 66 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 67 | }, 68 | { 69 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 70 | }, 71 | { 72 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 73 | }, 74 | ] 75 | 76 | LANGUAGE_CODE = 'en-us' 77 | 78 | TIME_ZONE = 'UTC' 79 | 80 | USE_I18N = True 81 | 82 | USE_L10N = True 83 | 84 | USE_TZ = True 85 | 86 | STATIC_URL = '/static/' 87 | 88 | # LOGGING = { 89 | # 'version': 1, 90 | # 'disable_existing_loggers': False, 91 | # 'handlers': { 92 | # 'console': { 93 | # 'class': 'logging.StreamHandler', 94 | # }, 95 | # }, 96 | # 'loggers': { 97 | # 'django': { 98 | # 'handlers': ['console'], 99 | # 'level': 'DEBUG', 100 | # }, 101 | # }, 102 | # } 103 | -------------------------------------------------------------------------------- /core/urls.py: -------------------------------------------------------------------------------- 1 | """core URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.10/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 | urlpatterns = [ 20 | url(r'^admin/', admin.site.urls), 21 | ] 22 | -------------------------------------------------------------------------------- /core/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for core 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.10/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", "core.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /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", "core.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 | Django==3.2.5 2 | ipython==7.31.1 3 | mysqlclient==2.0.3 4 | pytz==2021.1 5 | --------------------------------------------------------------------------------