From eb11156301abe120ebdd68a298193a1cb95bd813 Mon Sep 17 00:00:00 2001 From: Jerrica Bobadilla Date: Thu, 8 Oct 2020 10:51:39 -0700 Subject: [PATCH] initial files and contact model --- Pipfile | 13 +++ Pipfile.lock | 90 ++++++++++++++++++++ contacts/__init__.py | 0 contacts/admin.py | 3 + contacts/apps.py | 5 ++ contacts/migrations/0001_initial.py | 22 +++++ contacts/migrations/__init__.py | 0 contacts/models.py | 11 +++ contacts/tests.py | 3 + contacts/views.py | 3 + django_contacts/__init__.py | 0 django_contacts/asgi.py | 16 ++++ django_contacts/settings.py | 124 ++++++++++++++++++++++++++++ django_contacts/urls.py | 21 +++++ django_contacts/wsgi.py | 16 ++++ manage.py | 22 +++++ settings.sql | 3 + 17 files changed, 352 insertions(+) create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 contacts/__init__.py create mode 100644 contacts/admin.py create mode 100644 contacts/apps.py create mode 100644 contacts/migrations/0001_initial.py create mode 100644 contacts/migrations/__init__.py create mode 100644 contacts/models.py create mode 100644 contacts/tests.py create mode 100644 contacts/views.py create mode 100644 django_contacts/__init__.py create mode 100644 django_contacts/asgi.py create mode 100644 django_contacts/settings.py create mode 100644 django_contacts/urls.py create mode 100644 django_contacts/wsgi.py create mode 100755 manage.py create mode 100644 settings.sql diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..882c69e --- /dev/null +++ b/Pipfile @@ -0,0 +1,13 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +django = "*" +psycopg2-binary = "*" + +[requires] +python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..2f7d2d8 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,90 @@ +{ + "_meta": { + "hash": { + "sha256": "b04c44c86eca3e486ef2ab4a9a08c9c2c1531422cfe0123e55023fb1b157effc" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "asgiref": { + "hashes": [ + "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a", + "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed" + ], + "markers": "python_version >= '3.5'", + "version": "==3.2.10" + }, + "django": { + "hashes": [ + "sha256:a2127ad0150ec6966655bedf15dbbff9697cc86d61653db2da1afa506c0b04cc", + "sha256:c93c28ccf1d094cbd00d860e83128a39e45d2c571d3b54361713aaaf9a94cac4" + ], + "index": "pypi", + "version": "==3.1.2" + }, + "psycopg2-binary": { + "hashes": [ + "sha256:0deac2af1a587ae12836aa07970f5cb91964f05a7c6cdb69d8425ff4c15d4e2c", + "sha256:0e4dc3d5996760104746e6cfcdb519d9d2cd27c738296525d5867ea695774e67", + "sha256:11b9c0ebce097180129e422379b824ae21c8f2a6596b159c7659e2e5a00e1aa0", + "sha256:1fabed9ea2acc4efe4671b92c669a213db744d2af8a9fc5d69a8e9bc14b7a9db", + "sha256:2dac98e85565d5688e8ab7bdea5446674a83a3945a8f416ad0110018d1501b94", + "sha256:42ec1035841b389e8cc3692277a0bd81cdfe0b65d575a2c8862cec7a80e62e52", + "sha256:6a32f3a4cb2f6e1a0b15215f448e8ce2da192fd4ff35084d80d5e39da683e79b", + "sha256:7312e931b90fe14f925729cde58022f5d034241918a5c4f9797cac62f6b3a9dd", + "sha256:7d92a09b788cbb1aec325af5fcba9fed7203897bbd9269d5691bb1e3bce29550", + "sha256:833709a5c66ca52f1d21d41865a637223b368c0ee76ea54ca5bad6f2526c7679", + "sha256:8cd0fb36c7412996859cb4606a35969dd01f4ea34d9812a141cd920c3b18be77", + "sha256:950bc22bb56ee6ff142a2cb9ee980b571dd0912b0334aa3fe0fe3788d860bea2", + "sha256:a0c50db33c32594305b0ef9abc0cb7db13de7621d2cadf8392a1d9b3c437ef77", + "sha256:a0eb43a07386c3f1f1ebb4dc7aafb13f67188eab896e7397aa1ee95a9c884eb2", + "sha256:aaa4213c862f0ef00022751161df35804127b78adf4a2755b9f991a507e425fd", + "sha256:ac0c682111fbf404525dfc0f18a8b5f11be52657d4f96e9fcb75daf4f3984859", + "sha256:ad20d2eb875aaa1ea6d0f2916949f5c08a19c74d05b16ce6ebf6d24f2c9f75d1", + "sha256:b4afc542c0ac0db720cf516dd20c0846f71c248d2b3d21013aa0d4ef9c71ca25", + "sha256:b8a3715b3c4e604bcc94c90a825cd7f5635417453b253499664f784fc4da0152", + "sha256:ba28584e6bca48c59eecbf7efb1576ca214b47f05194646b081717fa628dfddf", + "sha256:ba381aec3a5dc29634f20692349d73f2d21f17653bda1decf0b52b11d694541f", + "sha256:bd1be66dde2b82f80afb9459fc618216753f67109b859a361cf7def5c7968729", + "sha256:c2507d796fca339c8fb03216364cca68d87e037c1f774977c8fc377627d01c71", + "sha256:cec7e622ebc545dbb4564e483dd20e4e404da17ae07e06f3e780b2dacd5cee66", + "sha256:d14b140a4439d816e3b1229a4a525df917d6ea22a0771a2a78332273fd9528a4", + "sha256:d1b4ab59e02d9008efe10ceabd0b31e79519da6fb67f7d8e8977118832d0f449", + "sha256:d5227b229005a696cc67676e24c214740efd90b148de5733419ac9aaba3773da", + "sha256:e1f57aa70d3f7cc6947fd88636a481638263ba04a742b4a37dd25c373e41491a", + "sha256:e74a55f6bad0e7d3968399deb50f61f4db1926acf4a6d83beaaa7df986f48b1c", + "sha256:e82aba2188b9ba309fd8e271702bd0d0fc9148ae3150532bbb474f4590039ffb", + "sha256:ee69dad2c7155756ad114c02db06002f4cded41132cc51378e57aad79cc8e4f4", + "sha256:f5ab93a2cb2d8338b1674be43b442a7f544a0971da062a5da774ed40587f18f5" + ], + "index": "pypi", + "version": "==2.8.6" + }, + "pytz": { + "hashes": [ + "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed", + "sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048" + ], + "version": "==2020.1" + }, + "sqlparse": { + "hashes": [ + "sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0", + "sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8" + ], + "markers": "python_version >= '3.5'", + "version": "==0.4.1" + } + }, + "develop": {} +} diff --git a/contacts/__init__.py b/contacts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/contacts/admin.py b/contacts/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/contacts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/contacts/apps.py b/contacts/apps.py new file mode 100644 index 0000000..ad6d0c8 --- /dev/null +++ b/contacts/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ContactsConfig(AppConfig): + name = 'contacts' diff --git a/contacts/migrations/0001_initial.py b/contacts/migrations/0001_initial.py new file mode 100644 index 0000000..3f2e2fe --- /dev/null +++ b/contacts/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.2 on 2020-10-08 17:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Contact', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('age', models.IntegerField()), + ], + ), + ] diff --git a/contacts/migrations/__init__.py b/contacts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/contacts/models.py b/contacts/models.py new file mode 100644 index 0000000..9cc3726 --- /dev/null +++ b/contacts/models.py @@ -0,0 +1,11 @@ +from django.db import models + +# Create your models here. + +## Contacts Model +class Contact(models.Model): + name = models.CharField(max_length=100) + age = models.IntegerField() + + def __str__(self): + return self.name diff --git a/contacts/tests.py b/contacts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/contacts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/contacts/views.py b/contacts/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/contacts/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/django_contacts/__init__.py b/django_contacts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_contacts/asgi.py b/django_contacts/asgi.py new file mode 100644 index 0000000..cbf7e43 --- /dev/null +++ b/django_contacts/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for django_contacts project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_contacts.settings') + +application = get_asgi_application() diff --git a/django_contacts/settings.py b/django_contacts/settings.py new file mode 100644 index 0000000..fdc5afd --- /dev/null +++ b/django_contacts/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for django_contacts project. + +Generated by 'django-admin startproject' using Django 3.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'n6&$_khrc&w%r&ufg$qmat915-4uhnoux)-_nttj&-0sxpn#dh' + +# 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', + 'contacts' +] + +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 = 'django_contacts.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 = 'django_contacts.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'contacts', + 'USER': 'contactsuser', + 'PASSWORD': 'contacts', + 'HOST': 'localhost' + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.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/3.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/3.1/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/django_contacts/urls.py b/django_contacts/urls.py new file mode 100644 index 0000000..f4b4032 --- /dev/null +++ b/django_contacts/urls.py @@ -0,0 +1,21 @@ +"""django_contacts URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.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/django_contacts/wsgi.py b/django_contacts/wsgi.py new file mode 100644 index 0000000..576c001 --- /dev/null +++ b/django_contacts/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for django_contacts 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/3.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_contacts.settings') + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..fce5fdf --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_contacts.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) + + +if __name__ == '__main__': + main() diff --git a/settings.sql b/settings.sql new file mode 100644 index 0000000..892d75c --- /dev/null +++ b/settings.sql @@ -0,0 +1,3 @@ +CREATE DATABASE contacts; +CREATE USER contactsuser WITH PASSWORD 'contacts'; +GRANT ALL PRIVILEGES ON DATABASE contacts TO contactsuser; \ No newline at end of file