From 123bbb294b09d67d9ecd3b4db5023cf40243ea1a Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Mon, 3 Dec 2018 17:44:54 -0500 Subject: [PATCH 1/9] added pipfiles --- Pipfile | 12 ++++++++++++ Pipfile.lock | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Pipfile create mode 100644 Pipfile.lock diff --git a/Pipfile b/Pipfile new file mode 100644 index 000000000..0d89d2841 --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[dev-packages] + +[packages] +django = "*" + +[requires] +python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 000000000..c05a7fba7 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,36 @@ +{ + "_meta": { + "hash": { + "sha256": "68309cd71a258c30a39567fce09a09ad5c4ff0bdc85b6fba22b47598c985c883" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "django": { + "hashes": [ + "sha256:068d51054083d06ceb32ce02b7203f1854256047a0d58682677dd4f81bceabd7", + "sha256:55409a056b27e6d1246f19ede41c6c610e4cab549c005b62cbeefabc6433356b" + ], + "index": "pypi", + "version": "==2.1.4" + }, + "pytz": { + "hashes": [ + "sha256:31cb35c89bd7d333cd32c5f278fca91b523b0834369e757f4c5641ea252236ca", + "sha256:8e0f8568c118d3077b46be7d654cc8167fa916092e28320cde048e54bfc9f1e6" + ], + "version": "==2018.7" + } + }, + "develop": {} +} From bea09e7bbf03a1f8b06b756368209179d7bb5745 Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Mon, 3 Dec 2018 18:53:24 -0500 Subject: [PATCH 2/9] progress day 1 --- django_app/__init__.py | 0 django_app/admin.py | 3 + django_app/apps.py | 5 + django_app/migrations/__init__.py | 0 django_app/models.py | 3 + django_app/tests.py | 3 + django_app/views.py | 3 + manage.py | 15 +++ project_django/__init__.py | 0 project_django/manage.py | 15 +++ project_django/project_django/__init__.py | 0 project_django/project_django/settings.py | 120 ++++++++++++++++++++++ project_django/project_django/urls.py | 21 ++++ project_django/project_django/wsgi.py | 16 +++ project_django/settings.py | 120 ++++++++++++++++++++++ project_django/urls.py | 21 ++++ project_django/wsgi.py | 16 +++ 17 files changed, 361 insertions(+) create mode 100644 django_app/__init__.py create mode 100644 django_app/admin.py create mode 100644 django_app/apps.py create mode 100644 django_app/migrations/__init__.py create mode 100644 django_app/models.py create mode 100644 django_app/tests.py create mode 100644 django_app/views.py create mode 100644 manage.py create mode 100644 project_django/__init__.py create mode 100644 project_django/manage.py create mode 100644 project_django/project_django/__init__.py create mode 100644 project_django/project_django/settings.py create mode 100644 project_django/project_django/urls.py create mode 100644 project_django/project_django/wsgi.py create mode 100644 project_django/settings.py create mode 100644 project_django/urls.py create mode 100644 project_django/wsgi.py diff --git a/django_app/__init__.py b/django_app/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/django_app/admin.py b/django_app/admin.py new file mode 100644 index 000000000..8c38f3f3d --- /dev/null +++ b/django_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/django_app/apps.py b/django_app/apps.py new file mode 100644 index 000000000..672e50bd5 --- /dev/null +++ b/django_app/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DjangoAppConfig(AppConfig): + name = 'django_app' diff --git a/django_app/migrations/__init__.py b/django_app/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/django_app/models.py b/django_app/models.py new file mode 100644 index 000000000..71a836239 --- /dev/null +++ b/django_app/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/django_app/tests.py b/django_app/tests.py new file mode 100644 index 000000000..7ce503c2d --- /dev/null +++ b/django_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django_app/views.py b/django_app/views.py new file mode 100644 index 000000000..91ea44a21 --- /dev/null +++ b/django_app/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/manage.py b/manage.py new file mode 100644 index 000000000..61ddca2b8 --- /dev/null +++ b/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == '__main__': + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_django.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) diff --git a/project_django/__init__.py b/project_django/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/project_django/manage.py b/project_django/manage.py new file mode 100644 index 000000000..61ddca2b8 --- /dev/null +++ b/project_django/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == '__main__': + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_django.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) diff --git a/project_django/project_django/__init__.py b/project_django/project_django/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/project_django/project_django/settings.py b/project_django/project_django/settings.py new file mode 100644 index 000000000..eafb33b11 --- /dev/null +++ b/project_django/project_django/settings.py @@ -0,0 +1,120 @@ +""" +Django settings for project_django project. + +Generated by 'django-admin startproject' using Django 2.1.4. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.1/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'mdqez08awr4*zu*jp+p(=y$2hq@r*98fd*ns__*-ix#2dq1nlu' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'project_django.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'project_django.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/project_django/project_django/urls.py b/project_django/project_django/urls.py new file mode 100644 index 000000000..13eb45def --- /dev/null +++ b/project_django/project_django/urls.py @@ -0,0 +1,21 @@ +"""project_django URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/project_django/project_django/wsgi.py b/project_django/project_django/wsgi.py new file mode 100644 index 000000000..5a7452c2c --- /dev/null +++ b/project_django/project_django/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for project_django project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_django.settings') + +application = get_wsgi_application() diff --git a/project_django/settings.py b/project_django/settings.py new file mode 100644 index 000000000..0f7cc3005 --- /dev/null +++ b/project_django/settings.py @@ -0,0 +1,120 @@ +""" +Django settings for project_django project. + +Generated by 'django-admin startproject' using Django 2.1.4. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.1/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '=w%iermv5+a9p80z&4e)y+9vfbo^9b_4vc5^z85lo20dvfi9-$' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'project_django.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'project_django.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/project_django/urls.py b/project_django/urls.py new file mode 100644 index 000000000..13eb45def --- /dev/null +++ b/project_django/urls.py @@ -0,0 +1,21 @@ +"""project_django URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/project_django/wsgi.py b/project_django/wsgi.py new file mode 100644 index 000000000..5a7452c2c --- /dev/null +++ b/project_django/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for project_django project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_django.settings') + +application = get_wsgi_application() From 2b2a1e412a63a048030c27938ad76fc47b188db6 Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Tue, 4 Dec 2018 18:49:25 -0500 Subject: [PATCH 3/9] got to SQL --- .gitignore | 1 + .vscode/settings.json | 4 ++++ Pipfile | 1 + Pipfile.lock | 9 ++++++- django_app/admin.py | 3 --- django_app/apps.py | 5 ---- django_app/models.py | 3 --- {django_app => notes}/__init__.py | 0 notes/admin.py | 11 +++++++++ notes/apps.py | 5 ++++ notes/migrations/0001_initial.py | 23 ++++++++++++++++++ notes/migrations/0002_auto_20181204_2331.py | 25 ++++++++++++++++++++ notes/migrations/0003_personalnote.py | 24 +++++++++++++++++++ {django_app => notes}/migrations/__init__.py | 0 notes/models.py | 15 ++++++++++++ {django_app => notes}/tests.py | 0 {django_app => notes}/views.py | 0 project_django/settings.py | 9 ++++--- 18 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 django_app/admin.py delete mode 100644 django_app/apps.py delete mode 100644 django_app/models.py rename {django_app => notes}/__init__.py (100%) create mode 100644 notes/admin.py create mode 100644 notes/apps.py create mode 100644 notes/migrations/0001_initial.py create mode 100644 notes/migrations/0002_auto_20181204_2331.py create mode 100644 notes/migrations/0003_personalnote.py rename {django_app => notes}/migrations/__init__.py (100%) create mode 100644 notes/models.py rename {django_app => notes}/tests.py (100%) rename {django_app => notes}/views.py (100%) diff --git a/.gitignore b/.gitignore index 894a44cc0..34e11d8b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.env # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..17df5c44e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.pythonPath": "C:\\Users\\agreb\\Anaconda3\\python.exe", + "python.linting.pylintEnabled": true +} \ No newline at end of file diff --git a/Pipfile b/Pipfile index 0d89d2841..aa4d2b3db 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,7 @@ name = "pypi" [packages] django = "*" +python-decouple = "*" [requires] python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index c05a7fba7..5fe3fabba 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "68309cd71a258c30a39567fce09a09ad5c4ff0bdc85b6fba22b47598c985c883" + "sha256": "70d328797ef7a3cabe10f317bff368858b238d531a67c8d105b196967a1d4055" }, "pipfile-spec": 6, "requires": { @@ -24,6 +24,13 @@ "index": "pypi", "version": "==2.1.4" }, + "python-decouple": { + "hashes": [ + "sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d" + ], + "index": "pypi", + "version": "==3.1" + }, "pytz": { "hashes": [ "sha256:31cb35c89bd7d333cd32c5f278fca91b523b0834369e757f4c5641ea252236ca", diff --git a/django_app/admin.py b/django_app/admin.py deleted file mode 100644 index 8c38f3f3d..000000000 --- a/django_app/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/django_app/apps.py b/django_app/apps.py deleted file mode 100644 index 672e50bd5..000000000 --- a/django_app/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class DjangoAppConfig(AppConfig): - name = 'django_app' diff --git a/django_app/models.py b/django_app/models.py deleted file mode 100644 index 71a836239..000000000 --- a/django_app/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/django_app/__init__.py b/notes/__init__.py similarity index 100% rename from django_app/__init__.py rename to notes/__init__.py diff --git a/notes/admin.py b/notes/admin.py new file mode 100644 index 000000000..e6e07983d --- /dev/null +++ b/notes/admin.py @@ -0,0 +1,11 @@ +from django.contrib import admin + +from .models import Note, PersonalNote + + +class NoteAdmin(admin.ModelAdmin): + readonly_fields = ('created_at', 'last_modified') + + +admin.site.register(Note, NoteAdmin) +admin.site.register(PersonalNote) diff --git a/notes/apps.py b/notes/apps.py new file mode 100644 index 000000000..b6155aca3 --- /dev/null +++ b/notes/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class NotesConfig(AppConfig): + name = 'notes' diff --git a/notes/migrations/0001_initial.py b/notes/migrations/0001_initial.py new file mode 100644 index 000000000..9c565ff8d --- /dev/null +++ b/notes/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.4 on 2018-12-04 20:37 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Note', + fields=[ + ('title', models.CharField(max_length=200)), + ('content', models.TextField(blank=True)), + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ], + ), + ] diff --git a/notes/migrations/0002_auto_20181204_2331.py b/notes/migrations/0002_auto_20181204_2331.py new file mode 100644 index 000000000..b21b496de --- /dev/null +++ b/notes/migrations/0002_auto_20181204_2331.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1.4 on 2018-12-04 23:31 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('notes', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='note', + name='created_at', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + migrations.AddField( + model_name='note', + name='last_modified', + field=models.DateTimeField(auto_now=True), + ), + ] diff --git a/notes/migrations/0003_personalnote.py b/notes/migrations/0003_personalnote.py new file mode 100644 index 000000000..ab9e8ae1a --- /dev/null +++ b/notes/migrations/0003_personalnote.py @@ -0,0 +1,24 @@ +# Generated by Django 2.1.4 on 2018-12-04 23:46 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('notes', '0002_auto_20181204_2331'), + ] + + operations = [ + migrations.CreateModel( + name='PersonalNote', + fields=[ + ('note_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='notes.Note')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + bases=('notes.note',), + ), + ] diff --git a/django_app/migrations/__init__.py b/notes/migrations/__init__.py similarity index 100% rename from django_app/migrations/__init__.py rename to notes/migrations/__init__.py diff --git a/notes/models.py b/notes/models.py new file mode 100644 index 000000000..dd94525df --- /dev/null +++ b/notes/models.py @@ -0,0 +1,15 @@ +from django.db import models +from uuid import uuid4 +# Create your models here. +from django.contrib.auth.models import User + +class Note(models.Model): + title = models.CharField(max_length=200) + content = models.TextField(blank=True) + id = models.UUIDField(primary_key=True, default=uuid4, editable=False) + + created_at = models.DateTimeField(auto_now_add=True) + last_modified = models.DateTimeField(auto_now=True) + +class PersonalNote(Note): + user = models.ForeignKey(User, on_delete=models.CASCADE) diff --git a/django_app/tests.py b/notes/tests.py similarity index 100% rename from django_app/tests.py rename to notes/tests.py diff --git a/django_app/views.py b/notes/views.py similarity index 100% rename from django_app/views.py rename to notes/views.py diff --git a/project_django/settings.py b/project_django/settings.py index 0f7cc3005..a45e0051f 100644 --- a/project_django/settings.py +++ b/project_django/settings.py @@ -12,6 +12,8 @@ import os +from decouple import config + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -20,10 +22,10 @@ # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '=w%iermv5+a9p80z&4e)y+9vfbo^9b_4vc5^z85lo20dvfi9-$' - +SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True + +DEBUG = config('DEBUG', cast=bool) ALLOWED_HOSTS = [] @@ -37,6 +39,7 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'notes', ] MIDDLEWARE = [ From 801aacc68431d0054118dcd58515fc6fa4df691c Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Wed, 5 Dec 2018 16:26:06 -0500 Subject: [PATCH 4/9] Days 3&4 --- Pipfile | 1 + Pipfile.lock | 10 +++++++++- notes/api.py | 29 +++++++++++++++++++++++++++++ project_django/settings.py | 12 ++++++++++++ project_django/urls.py | 12 +++++++++++- 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 notes/api.py diff --git a/Pipfile b/Pipfile index aa4d2b3db..c37a8f0ca 100644 --- a/Pipfile +++ b/Pipfile @@ -8,6 +8,7 @@ name = "pypi" [packages] django = "*" python-decouple = "*" +djangorestframework = "*" [requires] python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index 5fe3fabba..e03504b88 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "70d328797ef7a3cabe10f317bff368858b238d531a67c8d105b196967a1d4055" + "sha256": "2eaf437d6760c4cecd528e37e5649c8df095fd633c743fe1f5c734b598e61641" }, "pipfile-spec": 6, "requires": { @@ -24,6 +24,14 @@ "index": "pypi", "version": "==2.1.4" }, + "djangorestframework": { + "hashes": [ + "sha256:607865b0bb1598b153793892101d881466bd5a991de12bd6229abb18b1c86136", + "sha256:63f76cbe1e7d12b94c357d7e54401103b2e52aef0f7c1650d6c820ad708776e5" + ], + "index": "pypi", + "version": "==3.9.0" + }, "python-decouple": { "hashes": [ "sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d" diff --git a/notes/api.py b/notes/api.py new file mode 100644 index 000000000..fe7ada1a6 --- /dev/null +++ b/notes/api.py @@ -0,0 +1,29 @@ +from rest_framework import serializers, viewsets +from .models import PersonalNote + + +class PersonalNoteSerializer(serializers.HyperlinkedModelSerializer): + + class Meta: + model = PersonalNote + fields = ('title', 'content') + + def create(self, validated_data): + # import pdb; pdb.set_trace() + user = self.context['request'].user + note = PersonalNote.objects.create(user=user, **validated_data) + return note + + +class PersonalNoteViewSet(viewsets.ModelViewSet): + serializer_class = PersonalNoteSerializer + queryset = PersonalNote.objects.all() + + def get_queryset(self): + user = self.request.user + + if user.is_anonymous: + return PersonalNote.objects.none() + + else: + return PersonalNote.objects.filter(user=user) diff --git a/project_django/settings.py b/project_django/settings.py index a45e0051f..caae30b1b 100644 --- a/project_django/settings.py +++ b/project_django/settings.py @@ -40,6 +40,8 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'notes', + 'rest_framework', + 'rest_framework.authtoken', ] MIDDLEWARE = [ @@ -121,3 +123,13 @@ # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' + +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', + ], + + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + ) +} \ No newline at end of file diff --git a/project_django/urls.py b/project_django/urls.py index 13eb45def..3e5970bd5 100644 --- a/project_django/urls.py +++ b/project_django/urls.py @@ -14,8 +14,18 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include + +from rest_framework import routers +from notes.api import PersonalNoteViewSet + +router = routers.DefaultRouter() +router.register('notes', PersonalNoteViewSet) + +from rest_framework.authtoken import views urlpatterns = [ path('admin/', admin.site.urls), + path('api/', include(router.urls)), + path('api-token-auth/', views.obtain_auth_token), ] From 299c15f34402761e7e37929e2991b9585b536648 Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Thu, 6 Dec 2018 18:26:27 -0500 Subject: [PATCH 5/9] deliverables called Addresses done --- addresses/__init__.py | 0 addresses/admin.py | 11 +++++++++++ addresses/api.py | 29 ++++++++++++++++++++++++++++ addresses/apps.py | 5 +++++ addresses/migrations/0001_initial.py | 25 ++++++++++++++++++++++++ addresses/migrations/__init__.py | 0 addresses/models.py | 13 +++++++++++++ addresses/tests.py | 3 +++ addresses/views.py | 3 +++ notes/models.py | 2 ++ project_django/settings.py | 1 + 11 files changed, 92 insertions(+) create mode 100644 addresses/__init__.py create mode 100644 addresses/admin.py create mode 100644 addresses/api.py create mode 100644 addresses/apps.py create mode 100644 addresses/migrations/0001_initial.py create mode 100644 addresses/migrations/__init__.py create mode 100644 addresses/models.py create mode 100644 addresses/tests.py create mode 100644 addresses/views.py diff --git a/addresses/__init__.py b/addresses/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/addresses/admin.py b/addresses/admin.py new file mode 100644 index 000000000..222b64e81 --- /dev/null +++ b/addresses/admin.py @@ -0,0 +1,11 @@ +from django.contrib import admin +from .models import Address + + +class AddressAdmin(admin.ModelAdmin): + readonly_fields = ('logged_at', 'last_modified') + + +admin.site.register(Address, AddressAdmin) + +# Register your models here. diff --git a/addresses/api.py b/addresses/api.py new file mode 100644 index 000000000..452c35f53 --- /dev/null +++ b/addresses/api.py @@ -0,0 +1,29 @@ +from rest_framework import serializers, viewsets +from .models import Address + + +class AddressSerializer(serializers.HyperlinkedModelSerializer): + + class Meta: + model = Address + fields = ('friend', 'address') + + def create(self, validated_data): + # import pdb; pdb.set_trace() + user = self.context['request'].user + address = Address.objects.create(user=user, **validated_data) + return address + + +class AddressViewSet(viewsets.ModelViewSet): + serializer_class = AddressSerializer + queryset = Address.objects.none() + + def get_queryset(self): + user = self.request.user + + if user.is_anonymous: + return Address.objects.none() + + else: + return Address.objects.filter(user=user) diff --git a/addresses/apps.py b/addresses/apps.py new file mode 100644 index 000000000..7582c6ee4 --- /dev/null +++ b/addresses/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class AddressesConfig(AppConfig): + name = 'addresses' diff --git a/addresses/migrations/0001_initial.py b/addresses/migrations/0001_initial.py new file mode 100644 index 000000000..305f53499 --- /dev/null +++ b/addresses/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1.4 on 2018-12-06 22:52 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Address', + fields=[ + ('friend', models.CharField(max_length=200)), + ('address', models.TextField()), + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('logged_at', models.DateTimeField(auto_now_add=True)), + ('last_modified', models.DateTimeField(auto_now=True)), + ], + ), + ] diff --git a/addresses/migrations/__init__.py b/addresses/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/addresses/models.py b/addresses/models.py new file mode 100644 index 000000000..00ab41144 --- /dev/null +++ b/addresses/models.py @@ -0,0 +1,13 @@ +from django.db import models +from uuid import uuid4 +# Create your models here. +from django.contrib.auth.models import User + +class Address(models.Model): + friend = models.CharField(max_length=200) + address = models.TextField(blank=False) + id = models.UUIDField(primary_key=True, default=uuid4, editable=False) + + logged_at = models.DateTimeField(auto_now_add=True) + last_modified = models.DateTimeField(auto_now=True) +# Create your models here. diff --git a/addresses/tests.py b/addresses/tests.py new file mode 100644 index 000000000..7ce503c2d --- /dev/null +++ b/addresses/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/addresses/views.py b/addresses/views.py new file mode 100644 index 000000000..91ea44a21 --- /dev/null +++ b/addresses/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/notes/models.py b/notes/models.py index dd94525df..ae511b99d 100644 --- a/notes/models.py +++ b/notes/models.py @@ -13,3 +13,5 @@ class Note(models.Model): class PersonalNote(Note): user = models.ForeignKey(User, on_delete=models.CASCADE) + + diff --git a/project_django/settings.py b/project_django/settings.py index caae30b1b..a567b8f30 100644 --- a/project_django/settings.py +++ b/project_django/settings.py @@ -42,6 +42,7 @@ 'notes', 'rest_framework', 'rest_framework.authtoken', + 'addresses', ] MIDDLEWARE = [ From abedf92c753afe652bd7cfe44b8086c9425a8596 Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Fri, 7 Dec 2018 12:12:38 -0500 Subject: [PATCH 6/9] getting ready to deploy --- Pipfile | 5 ++ Pipfile.lock | 110 ++++++++++++++++++++++++++++++++++++- procfile | 1 + project_django/settings.py | 13 ++++- requirements.txt | 1 + 5 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 procfile create mode 100644 requirements.txt diff --git a/Pipfile b/Pipfile index c37a8f0ca..4401605c0 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,11 @@ name = "pypi" django = "*" python-decouple = "*" djangorestframework = "*" +heroku = "*" +gunicorn = "*" +"psycopg2-binary" = "*" +dj-database-url = "*" +whitenoise = "*" [requires] python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index e03504b88..76b74b501 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "2eaf437d6760c4cecd528e37e5649c8df095fd633c743fe1f5c734b598e61641" + "sha256": "93fd58795caddff3f7e42ca800c5e46377cf4d39b3d0c48a9ff3c85db83bfb3f" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,28 @@ ] }, "default": { + "certifi": { + "hashes": [ + "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", + "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" + ], + "version": "==2018.11.29" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "dj-database-url": { + "hashes": [ + "sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163", + "sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9" + ], + "index": "pypi", + "version": "==0.5.0" + }, "django": { "hashes": [ "sha256:068d51054083d06ceb32ce02b7203f1854256047a0d58682677dd4f81bceabd7", @@ -32,6 +54,70 @@ "index": "pypi", "version": "==3.9.0" }, + "gunicorn": { + "hashes": [ + "sha256:aa8e0b40b4157b36a5df5e599f45c9c76d6af43845ba3b3b0efe2c70473c2471", + "sha256:fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3" + ], + "index": "pypi", + "version": "==19.9.0" + }, + "heroku": { + "hashes": [ + "sha256:cbeba42b628bc38504d49ace86b8c1729ab2156e530fb1823954988932c8f7fb" + ], + "index": "pypi", + "version": "==0.1.4" + }, + "idna": { + "hashes": [ + "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e", + "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16" + ], + "version": "==2.7" + }, + "psycopg2-binary": { + "hashes": [ + "sha256:036bcb198a7cc4ce0fe43344f8c2c9a8155aefa411633f426c8c6ed58a6c0426", + "sha256:1d770fcc02cdf628aebac7404d56b28a7e9ebec8cfc0e63260bd54d6edfa16d4", + "sha256:1fdc6f369dcf229de6c873522d54336af598b9470ccd5300e2f58ee506f5ca13", + "sha256:21f9ddc0ff6e07f7d7b6b484eb9da2c03bc9931dd13e36796b111d631f7135a3", + "sha256:247873cda726f7956f745a3e03158b00de79c4abea8776dc2f611d5ba368d72d", + "sha256:3aa31c42f29f1da6f4fd41433ad15052d5ff045f2214002e027a321f79d64e2c", + "sha256:475f694f87dbc619010b26de7d0fc575a4accf503f2200885cc21f526bffe2ad", + "sha256:4b5e332a24bf6e2fda1f51ca2a57ae1083352293a08eeea1fa1112dc7dd542d1", + "sha256:570d521660574aca40be7b4d532dfb6f156aad7b16b5ed62d1534f64f1ef72d8", + "sha256:59072de7def0690dd13112d2bdb453e20570a97297070f876fbbb7cbc1c26b05", + "sha256:5f0b658989e918ef187f8a08db0420528126f2c7da182a7b9f8bf7f85144d4e4", + "sha256:649199c84a966917d86cdc2046e03d536763576c0b2a756059ae0b3a9656bc20", + "sha256:6645fc9b4705ae8fbf1ef7674f416f89ae1559deec810f6dd15197dfa52893da", + "sha256:6872dd54d4e398d781efe8fe2e2d7eafe4450d61b5c4898aced7610109a6df75", + "sha256:6ce34fbc251fc0d691c8d131250ba6f42fd2b28ef28558d528ba8c558cb28804", + "sha256:73920d167a0a4d1006f5f3b9a3efce6f0e5e883a99599d38206d43f27697df00", + "sha256:8a671732b87ae423e34b51139628123bc0306c2cb85c226e71b28d3d57d7e42a", + "sha256:8d517e8fda2efebca27c2018e14c90ed7dc3f04d7098b3da2912e62a1a5585fe", + "sha256:9475a008eb7279e20d400c76471843c321b46acacc7ee3de0b47233a1e3fa2cf", + "sha256:96947b8cd7b3148fb0e6549fcb31258a736595d6f2a599f8cd450e9a80a14781", + "sha256:abf229f24daa93f67ac53e2e17c8798a71a01711eb9fcdd029abba8637164338", + "sha256:b1ab012f276df584beb74f81acb63905762c25803ece647016613c3d6ad4e432", + "sha256:b22b33f6f0071fe57cb4e9158f353c88d41e739a3ec0d76f7b704539e7076427", + "sha256:b3b2d53274858e50ad2ffdd6d97ce1d014e1e530f82ec8b307edd5d4c921badf", + "sha256:bab26a729befc7b9fab9ded1bba9c51b785188b79f8a2796ba03e7e734269e2e", + "sha256:daa1a593629aa49f506eddc9d23dc7f89b35693b90e1fbcd4480182d1203ea90", + "sha256:dd111280ce40e89fd17b19c1269fd1b74a30fce9d44a550840e86edb33924eb8", + "sha256:e0b86084f1e2e78c451994410de756deba206884d6bed68d5a3d7f39ff5fea1d", + "sha256:eb86520753560a7e89639500e2a254bb6f683342af598088cb72c73edcad21e6", + "sha256:ff18c5c40a38d41811c23e2480615425c97ea81fd7e9118b8b899c512d97c737" + ], + "index": "pypi", + "version": "==2.7.6.1" + }, + "python-dateutil": { + "hashes": [ + "sha256:6f197348b46fb8cdf9f3fcfc2a7d5a97da95db3e2e8667cf657216274fe1b009" + ], + "version": "==1.5" + }, "python-decouple": { "hashes": [ "sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d" @@ -45,6 +131,28 @@ "sha256:8e0f8568c118d3077b46be7d654cc8167fa916092e28320cde048e54bfc9f1e6" ], "version": "==2018.7" + }, + "requests": { + "hashes": [ + "sha256:65b3a120e4329e33c9889db89c80976c5272f56ea92d3e74da8a463992e3ff54", + "sha256:ea881206e59f41dbd0bd445437d792e43906703fff75ca8ff43ccdb11f33f263" + ], + "version": "==2.20.1" + }, + "urllib3": { + "hashes": [ + "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", + "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" + ], + "version": "==1.24.1" + }, + "whitenoise": { + "hashes": [ + "sha256:118ab3e5f815d380171b100b05b76de2a07612f422368a201a9ffdeefb2251c1", + "sha256:42133ddd5229eeb6a0c9899496bdbe56c292394bf8666da77deeb27454c0456a" + ], + "index": "pypi", + "version": "==4.1.2" } }, "develop": {} diff --git a/procfile b/procfile new file mode 100644 index 000000000..9b3fdd2dc --- /dev/null +++ b/procfile @@ -0,0 +1 @@ +web: gunicorn project_django.wsgi --log-file - \ No newline at end of file diff --git a/project_django/settings.py b/project_django/settings.py index a567b8f30..c2ed2ce35 100644 --- a/project_django/settings.py +++ b/project_django/settings.py @@ -12,7 +12,13 @@ import os -from decouple import config + +import dj_database_url + + + +from decouple import config + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -46,6 +52,8 @@ ] MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -85,7 +93,7 @@ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } - +DATABASES['default'] = dj_database_url.config(default=config('DATABASE_URL'), conn_max_age=600) # Password validation # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators @@ -124,6 +132,7 @@ # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' +STATIC_ROOT = os.path.join(BASE_DIR, 'static') REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..a45710b31 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pip freeze > requirements.txt \ No newline at end of file From 86b37a8657b6379a34ed28cf696fa4905a67b0ee Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Fri, 7 Dec 2018 13:15:55 -0500 Subject: [PATCH 7/9] changing allowed_hosts --- project_django/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_django/settings.py b/project_django/settings.py index c2ed2ce35..c7a6e2b33 100644 --- a/project_django/settings.py +++ b/project_django/settings.py @@ -33,7 +33,7 @@ DEBUG = config('DEBUG', cast=bool) -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = config('ALLOWED_HOSTS').split(',') # Application definition From 7b62eeb86ad1ae977600d401c1361f2d88ef762e Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Fri, 7 Dec 2018 13:24:49 -0500 Subject: [PATCH 8/9] changed Procfile --- procfile => Procfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename procfile => Procfile (100%) diff --git a/procfile b/Procfile similarity index 100% rename from procfile rename to Procfile From 19127dbf3f79ef69087d4b71bb582837bdee11a2 Mon Sep 17 00:00:00 2001 From: Anthony Greb Date: Fri, 7 Dec 2018 13:28:23 -0500 Subject: [PATCH 9/9] deleted nested folder --- project_django/project_django/__init__.py | 0 project_django/project_django/settings.py | 120 ---------------------- project_django/project_django/urls.py | 21 ---- project_django/project_django/wsgi.py | 16 --- 4 files changed, 157 deletions(-) delete mode 100644 project_django/project_django/__init__.py delete mode 100644 project_django/project_django/settings.py delete mode 100644 project_django/project_django/urls.py delete mode 100644 project_django/project_django/wsgi.py diff --git a/project_django/project_django/__init__.py b/project_django/project_django/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/project_django/project_django/settings.py b/project_django/project_django/settings.py deleted file mode 100644 index eafb33b11..000000000 --- a/project_django/project_django/settings.py +++ /dev/null @@ -1,120 +0,0 @@ -""" -Django settings for project_django project. - -Generated by 'django-admin startproject' using Django 2.1.4. - -For more information on this file, see -https://docs.djangoproject.com/en/2.1/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.1/ref/settings/ -""" - -import os - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'mdqez08awr4*zu*jp+p(=y$2hq@r*98fd*ns__*-ix#2dq1nlu' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'project_django.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'project_django.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/2.1/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - - -# Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ - -STATIC_URL = '/static/' diff --git a/project_django/project_django/urls.py b/project_django/project_django/urls.py deleted file mode 100644 index 13eb45def..000000000 --- a/project_django/project_django/urls.py +++ /dev/null @@ -1,21 +0,0 @@ -"""project_django URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.1/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import path - -urlpatterns = [ - path('admin/', admin.site.urls), -] diff --git a/project_django/project_django/wsgi.py b/project_django/project_django/wsgi.py deleted file mode 100644 index 5a7452c2c..000000000 --- a/project_django/project_django/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for project_django project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_django.settings') - -application = get_wsgi_application()