From 739571347d87135babd03ba2c9c02661b73c287d Mon Sep 17 00:00:00 2001 From: Rushil Umaretiya Date: Tue, 15 Feb 2022 17:59:28 -0500 Subject: [PATCH] initial commit --- .gitignore | 137 +++++++++++++++++++++++++++++++++ Pipfile | 15 ++++ Pipfile.lock | 89 +++++++++++++++++++++ config/__init__.py | 0 config/asgi.py | 16 ++++ config/settings.py | 135 ++++++++++++++++++++++++++++++++ config/urls.py | 22 ++++++ config/wsgi.py | 16 ++++ form/__init__.py | 0 form/admin.py | 3 + form/apps.py | 6 ++ form/forms.py | 9 +++ form/migrations/__init__.py | 0 form/models.py | 17 ++++ form/templates/form/base.html | 12 +++ form/templates/form/index.html | 4 + form/tests.py | 3 + form/urls.py | 6 ++ form/views.py | 6 ++ manage.py | 22 ++++++ 20 files changed, 518 insertions(+) create mode 100644 .gitignore create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 config/__init__.py create mode 100644 config/asgi.py create mode 100644 config/settings.py create mode 100644 config/urls.py create mode 100644 config/wsgi.py create mode 100644 form/__init__.py create mode 100644 form/admin.py create mode 100644 form/apps.py create mode 100644 form/forms.py create mode 100644 form/migrations/__init__.py create mode 100644 form/models.py create mode 100644 form/templates/form/base.html create mode 100644 form/templates/form/index.html create mode 100644 form/tests.py create mode 100644 form/urls.py create mode 100644 form/views.py create mode 100755 manage.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56a04c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,137 @@ +# Django # +*.log +*.pot +*.pyc +__pycache__ +db.sqlite3 +media + +# Backup files # +*.bak + +# If you are using PyCharm # +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# File-based project format +*.iws + +# IntelliJ +out/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Python # +*.py[cod] +*$py.class + +# Distribution / packaging +.Python build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery +celerybeat-schedule.* + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# Sublime Text # +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache +*.sublime-workspace +*.sublime-project + +# sftp configuration file +sftp-config.json + +# Package control specific files Package +Control.last-run +Control.ca-list +Control.ca-bundle +Control.system-ca-bundle +GitHub.sublime-settings + +# Visual Studio Code # +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..b55c9de --- /dev/null +++ b/Pipfile @@ -0,0 +1,15 @@ +[[source]] +url = "https://pypi.python.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +django = "*" +python-dotenv = "*" +django-phonenumber-field = "*" +django-address = "*" + +[dev-packages] + +[requires] +python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..2e68b35 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,89 @@ +{ + "_meta": { + "hash": { + "sha256": "008f09930a447935f2210147becbc00e5519c714f2b19b07647972de19557cc4" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "asgiref": { + "hashes": [ + "sha256:2f8abc20f7248433085eda803936d98992f1343ddb022065779f37c5da0181d0", + "sha256:88d59c13d634dcffe0510be048210188edd79aeccb6a6c9028cdad6f31d730a9" + ], + "version": "==3.5.0" + }, + "backports.zoneinfo": { + "hashes": [ + "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf", + "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328", + "sha256:1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546", + "sha256:4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6", + "sha256:5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570", + "sha256:7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9", + "sha256:8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7", + "sha256:8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987", + "sha256:89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722", + "sha256:a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582", + "sha256:da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc", + "sha256:e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b", + "sha256:e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1", + "sha256:e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08", + "sha256:f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac", + "sha256:fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2" + ], + "markers": "python_version < '3.9'", + "version": "==0.2.1" + }, + "django": { + "hashes": [ + "sha256:110fb58fb12eca59e072ad59fc42d771cd642dd7a2f2416582aa9da7a8ef954a", + "sha256:996495c58bff749232426c88726d8cd38d24c94d7c1d80835aafffa9bc52985a" + ], + "index": "pypi", + "version": "==4.0.2" + }, + "django-address": { + "hashes": [ + "sha256:1918a92ab56cfe9df1976b940256d90b1230d9ae08c0e38e18ea645e78e84f02", + "sha256:75d7fb77d1eaba0e612e361d6e6794f55f1810971d46c13cfb49d8802634fcab" + ], + "index": "pypi", + "version": "==0.2.5" + }, + "django-phonenumber-field": { + "hashes": [ + "sha256:897b902a1654b0eb21f6268498a3359e2c4eb90af9585cb8693af186ede8c5bb", + "sha256:b1ff950f90a8911ff323ccf77c8f6fe4299a9f671fa61c8734a6994359f07446" + ], + "index": "pypi", + "version": "==6.1.0" + }, + "python-dotenv": { + "hashes": [ + "sha256:32b2bdc1873fd3a3c346da1c6db83d0053c3c62f28f1f38516070c4c8971b1d3", + "sha256:a5de49a31e953b45ff2d2fd434bbc2670e8db5273606c1e737cc6b93eff3655f" + ], + "index": "pypi", + "version": "==0.19.2" + }, + "sqlparse": { + "hashes": [ + "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae", + "sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d" + ], + "version": "==0.4.2" + } + }, + "develop": {} +} diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/asgi.py b/config/asgi.py new file mode 100644 index 0000000..f2191c2 --- /dev/null +++ b/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config 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/4.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') + +application = get_asgi_application() diff --git a/config/settings.py b/config/settings.py new file mode 100644 index 0000000..f5114e1 --- /dev/null +++ b/config/settings.py @@ -0,0 +1,135 @@ +""" +Django settings for config project. + +Generated by 'django-admin startproject' using Django 4.0.2. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.0/ref/settings/ +""" + +from pathlib import Path + +import os +from dotenv import load_dotenv + +load_dotenv() + +# 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/4.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = os.getenv("DEBUG", "False") == "True" + +if DEBUG: + ALLOWED_HOSTS = ['*'] +else: + ALLOWED_HOSTS = ['relish.monster'] + +# Application definition + +INSTALLED_APPS = [ + 'phonenumber_field', + 'address', + + 'form', + + '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 = 'config.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 = 'config.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.0/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/4.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.0/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/config/urls.py b/config/urls.py new file mode 100644 index 0000000..3ba1a61 --- /dev/null +++ b/config/urls.py @@ -0,0 +1,22 @@ +"""config URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.0/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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('form.urls')) +] diff --git a/config/wsgi.py b/config/wsgi.py new file mode 100644 index 0000000..08031f8 --- /dev/null +++ b/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config 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/4.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') + +application = get_wsgi_application() diff --git a/form/__init__.py b/form/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/form/admin.py b/form/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/form/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/form/apps.py b/form/apps.py new file mode 100644 index 0000000..d94fe57 --- /dev/null +++ b/form/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class FormConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'form' diff --git a/form/forms.py b/form/forms.py new file mode 100644 index 0000000..de2b7a5 --- /dev/null +++ b/form/forms.py @@ -0,0 +1,9 @@ +from ast import Mod +import imp +from django.forms import ModelForm +from .models import Response + +class ResponseForm(ModelForm): + class Meta: + model = Response + fields = ['name', 'email', 'phone', 'address'] \ No newline at end of file diff --git a/form/migrations/__init__.py b/form/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/form/models.py b/form/models.py new file mode 100644 index 0000000..4cb4fd1 --- /dev/null +++ b/form/models.py @@ -0,0 +1,17 @@ +from django.db import models + +# Create your models here. +class Response(models.Model): + + name = models.CharField(max_length=100) + email = models.EmailField(max_length=100) + text = models.TextField() + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.name + + class Meta: + verbose_name = 'Response' + verbose_name_plural = 'Responses' + ordering = ['created_at'] diff --git a/form/templates/form/base.html b/form/templates/form/base.html new file mode 100644 index 0000000..5c229db --- /dev/null +++ b/form/templates/form/base.html @@ -0,0 +1,12 @@ + + + + + + + Internet Form + + + {% block content %}{% endblock %} + + \ No newline at end of file diff --git a/form/templates/form/index.html b/form/templates/form/index.html new file mode 100644 index 0000000..09d595e --- /dev/null +++ b/form/templates/form/index.html @@ -0,0 +1,4 @@ +{% extends 'form/base.html' %} +{% block content %} +

index.

+{% endblock %} \ No newline at end of file diff --git a/form/tests.py b/form/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/form/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/form/urls.py b/form/urls.py new file mode 100644 index 0000000..fcccd7a --- /dev/null +++ b/form/urls.py @@ -0,0 +1,6 @@ +from django.urls import path, include +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] diff --git a/form/views.py b/form/views.py new file mode 100644 index 0000000..6d53f77 --- /dev/null +++ b/form/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render + +# Create your views here. +def index(request): + if request.method == 'GET': + return render(request, 'form/index.html') \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..8e7ac79 --- /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', 'config.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()