├── README.md ├── django-cbvs-tutorial ├── db.sqlite3 ├── manage.py ├── sampleapp │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── settings.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ └── wsgi.cpython-36.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── snippets │ ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── admin.cpython-36.pyc │ ├── models.cpython-36.pyc │ ├── urls.cpython-36.pyc │ └── views.cpython-36.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ ├── 0001_initial.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ ├── models.py │ ├── templates │ └── snippets │ │ ├── base.html │ │ ├── snippet_detail.html │ │ └── snippet_list.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── django-models-tutorial ├── db.sqlite3 ├── manage.py ├── sampleapp │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── settings.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ └── wsgi.cpython-36.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── snippets │ ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── admin.cpython-36.pyc │ ├── models.cpython-36.pyc │ ├── urls.cpython-36.pyc │ └── views.cpython-36.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ ├── 0001_initial.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ ├── models.py │ ├── templates │ └── snippets │ │ ├── _box.html │ │ ├── base.html │ │ ├── snippet_detail.html │ │ └── snippet_list.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── django-setup-tutorial ├── manage.py ├── sampleapp │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── settings.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ └── wsgi.cpython-36.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── snippets │ ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── admin.cpython-36.pyc │ ├── models.cpython-36.pyc │ ├── urls.cpython-36.pyc │ └── views.cpython-36.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ └── __pycache__ │ │ └── __init__.cpython-36.pyc │ ├── models.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── django-templates-tutorial ├── manage.py ├── sampleapp │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── settings.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ └── wsgi.cpython-36.pyc │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── snippets │ ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── admin.cpython-36.pyc │ ├── models.cpython-36.pyc │ ├── urls.cpython-36.pyc │ └── views.cpython-36.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ └── __pycache__ │ │ └── __init__.cpython-36.pyc │ ├── models.py │ ├── static │ └── styles.css │ ├── templates │ └── snippets │ │ ├── _box.html │ │ ├── base.html │ │ └── snippet_list.html │ ├── tests.py │ ├── urls.py │ └── views.py └── django-urls-tutorial ├── manage.py ├── sampleapp ├── __pycache__ │ ├── __init__.cpython-36.pyc │ ├── settings.cpython-36.pyc │ ├── urls.cpython-36.pyc │ └── wsgi.cpython-36.pyc ├── settings.py ├── urls.py └── wsgi.py └── snippets ├── __pycache__ ├── __init__.cpython-36.pyc ├── admin.cpython-36.pyc ├── models.cpython-36.pyc ├── urls.cpython-36.pyc └── views.cpython-36.pyc ├── admin.py ├── apps.py ├── migrations └── __pycache__ │ └── __init__.cpython-36.pyc ├── models.py ├── tests.py ├── urls.py └── views.py /README.md: -------------------------------------------------------------------------------- 1 | # django-fundamentals-tutorial 2 | 3 | Code repository for the django fundamentals series on youtube: https://www.youtube.com/playlist?list=PLbpAWbHbi5rMM3i--gfgjwQ404DZmwwd3 4 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/db.sqlite3 -------------------------------------------------------------------------------- /django-cbvs-tutorial/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", "sampleapp.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for sampleapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 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 | 'snippets' 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 = 'sampleapp.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 = 'sampleapp.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/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/2.0/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/2.0/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/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('snippets/', include('snippets.urls', namespace='snippets')), 7 | path('admin/', admin.site.urls), 8 | ] 9 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/sampleapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for sampleapp 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/2.0/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", "sampleapp.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-13 07:59 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='Snippet', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=100)), 19 | ('body', models.TextField()), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-cbvs-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Snippet(models.Model): 5 | title = models.CharField(max_length=100) 6 | body = models.TextField() 7 | created = models.DateTimeField(auto_now_add=True) 8 | 9 | def __str__(self): 10 | return self.title 11 | 12 | def body_preview(self): 13 | return self.body[:50] 14 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/templates/snippets/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/templates/snippets/snippet_detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet Detail{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

{{ snippet.title }}

8 | 9 |
10 |   {{ snippet.body_preview }}
11 | 
12 | 13 | {% endblock content %} 14 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 | {{ is_expired }} 8 | 9 | 16 | 17 | {% endblock content %} 18 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.SnippetListView.as_view(), name='list'), 8 | path('/', views.SnippetDetailView.as_view(), name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /django-cbvs-tutorial/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | from .models import Snippet 5 | from django.views import View 6 | from django.views.generic import ListView, DetailView 7 | 8 | 9 | class SnippetListView(ListView): 10 | model = Snippet 11 | template_name = 'snippets/snippet_list.html' 12 | 13 | # Use the following snippet to override the context data 14 | 15 | # def get_context_data(self, **kwargs): 16 | # context = super().get_context_data(**kwargs) 17 | # # access context dictionary here... 18 | # return context 19 | 20 | 21 | class SnippetDetailView(DetailView): 22 | model = Snippet 23 | template_name = 'snippets/snippet_detail.html' 24 | -------------------------------------------------------------------------------- /django-models-tutorial/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/db.sqlite3 -------------------------------------------------------------------------------- /django-models-tutorial/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", "sampleapp.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for sampleapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 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 | 'snippets' 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 = 'sampleapp.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 = 'sampleapp.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/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/2.0/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/2.0/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/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('snippets/', include('snippets.urls', namespace='snippets')), 7 | path('admin/', admin.site.urls), 8 | ] 9 | -------------------------------------------------------------------------------- /django-models-tutorial/sampleapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for sampleapp 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/2.0/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", "sampleapp.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-13 07:59 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='Snippet', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=100)), 19 | ('body', models.TextField()), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-models-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-models-tutorial/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Snippet(models.Model): 5 | title = models.CharField(max_length=100) 6 | body = models.TextField() 7 | created = models.DateTimeField(auto_now_add=True) 8 | 9 | def __str__(self): 10 | return self.title 11 | 12 | def body_preview(self): 13 | return self.body[:50] 14 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/templates/snippets/_box.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/templates/snippets/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/templates/snippets/snippet_detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet Detail{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

{{ snippet.title }}

8 | 9 |
10 |   {{ snippet.body_preview }}
11 | 
12 | 13 | {% endblock content %} 14 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 | {{ is_expired }} 8 | 9 | 16 | 17 | {% endblock content %} 18 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.snippet_list, name='list'), 8 | path('/', views.snippet_detail, name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /django-models-tutorial/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | from .models import Snippet 5 | 6 | def snippet_list(request): 7 | snippet_list = Snippet.objects.all() 8 | return render(request, 'snippets/snippet_list.html', {'snippet_list': snippet_list}) 9 | 10 | def snippet_detail(request, id): 11 | snippet = get_object_or_404(Snippet, id=id) 12 | return render(request, 'snippets/snippet_detail.html', {'snippet': snippet}) 13 | -------------------------------------------------------------------------------- /django-setup-tutorial/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", "sampleapp.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for sampleapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 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 | 'snippets' 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 = 'sampleapp.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 = 'sampleapp.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/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/2.0/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/2.0/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/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('snippets/', include('snippets.urls', namespace='snippets')), 7 | path('admin/', admin.site.urls), 8 | ] 9 | -------------------------------------------------------------------------------- /django-setup-tutorial/sampleapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for sampleapp 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/2.0/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", "sampleapp.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-setup-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.snippet_list, name='list'), 8 | path('/', views.snippet_detail, name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /django-setup-tutorial/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | 5 | 6 | def snippet_list(request): 7 | print(reverse('snippets:list')) 8 | return HttpResponse('snippet list...') 9 | 10 | def snippet_detail(request, id): 11 | return HttpResponse(f'snippet detail with the id of {id}') 12 | -------------------------------------------------------------------------------- /django-templates-tutorial/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", "sampleapp.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for sampleapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 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 | 'snippets' 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 = 'sampleapp.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 = 'sampleapp.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/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/2.0/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/2.0/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/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('snippets/', include('snippets.urls', namespace='snippets')), 7 | path('admin/', admin.site.urls), 8 | ] 9 | -------------------------------------------------------------------------------- /django-templates-tutorial/sampleapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for sampleapp 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/2.0/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", "sampleapp.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-templates-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/static/styles.css: -------------------------------------------------------------------------------- 1 | * { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/templates/snippets/_box.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/templates/snippets/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

This should be red now...

8 | 9 | {% endblock content %} 10 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.snippet_list, name='list'), 8 | path('/', views.snippet_detail, name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /django-templates-tutorial/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | 5 | 6 | def snippet_list(request): 7 | name = 'bob' 8 | is_expired = False 9 | return render(request, 'snippets/snippet_list.html', {'name': name, 'is_expired': is_expired}) 10 | 11 | def snippet_detail(request, id): 12 | return HttpResponse(f'snippet detail with the id of {id}') 13 | -------------------------------------------------------------------------------- /django-urls-tutorial/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", "sampleapp.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/sampleapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/sampleapp/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/sampleapp/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/sampleapp/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for sampleapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 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 | 'snippets' 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 = 'sampleapp.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 = 'sampleapp.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/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/2.0/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/2.0/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/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('snippets/', include('snippets.urls', namespace='snippets')), 7 | path('admin/', admin.site.urls), 8 | ] 9 | -------------------------------------------------------------------------------- /django-urls-tutorial/sampleapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for sampleapp 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/2.0/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", "sampleapp.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-fundamentals-tutorial/34949d8c8cd7ed86e054b2477e9cbe0909a9bb58/django-urls-tutorial/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.snippet_list, name='list'), 8 | path('/', views.snippet_detail, name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /django-urls-tutorial/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | 5 | 6 | def snippet_list(request): 7 | print(reverse('snippets:list')) 8 | return HttpResponse('snippet list...') 9 | 10 | def snippet_detail(request, id): 11 | return HttpResponse(f'snippet detail with the id of {id}') 12 | --------------------------------------------------------------------------------