From c70a2f1aeb26947d4d6ad145eee7220080841906 Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Sat, 23 Nov 2024 12:28:00 +0000 Subject: [PATCH] initial django project --- .python-version | 1 + penparse/manage.py | 22 +++++ penparse/penparse/__init__.py | 0 penparse/penparse/asgi.py | 16 ++++ penparse/penparse/settings.py | 124 ++++++++++++++++++++++++++ penparse/penparse/urls.py | 25 ++++++ penparse/penparse/wsgi.py | 16 ++++ penparse/webui/__init__.py | 0 penparse/webui/admin.py | 3 + penparse/webui/apps.py | 6 ++ penparse/webui/migrations/__init__.py | 0 penparse/webui/models.py | 3 + penparse/webui/tests.py | 3 + penparse/webui/urls.py | 7 ++ penparse/webui/views.py | 6 ++ pyproject.toml | 9 ++ uv.lock | 66 ++++++++++++++ 17 files changed, 307 insertions(+) create mode 100644 .python-version create mode 100755 penparse/manage.py create mode 100644 penparse/penparse/__init__.py create mode 100644 penparse/penparse/asgi.py create mode 100644 penparse/penparse/settings.py create mode 100644 penparse/penparse/urls.py create mode 100644 penparse/penparse/wsgi.py create mode 100644 penparse/webui/__init__.py create mode 100644 penparse/webui/admin.py create mode 100644 penparse/webui/apps.py create mode 100644 penparse/webui/migrations/__init__.py create mode 100644 penparse/webui/models.py create mode 100644 penparse/webui/tests.py create mode 100644 penparse/webui/urls.py create mode 100644 penparse/webui/views.py create mode 100644 pyproject.toml create mode 100644 uv.lock diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..bd28b9c --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9 diff --git a/penparse/manage.py b/penparse/manage.py new file mode 100755 index 0000000..82a4f07 --- /dev/null +++ b/penparse/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', 'penparse.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/penparse/penparse/__init__.py b/penparse/penparse/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/penparse/penparse/asgi.py b/penparse/penparse/asgi.py new file mode 100644 index 0000000..ca4a31a --- /dev/null +++ b/penparse/penparse/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for penparse 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.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'penparse.settings') + +application = get_asgi_application() diff --git a/penparse/penparse/settings.py b/penparse/penparse/settings.py new file mode 100644 index 0000000..c1c2e48 --- /dev/null +++ b/penparse/penparse/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for penparse project. + +Generated by 'django-admin startproject' using Django 4.2.16. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.2/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/4.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-t5yq5dlvztd^-oq%*($@lj$$33l_73e05093xw7s0)-ekqhtfn' + +# 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', + 'webui' +] + +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 = 'penparse.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 = 'penparse.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/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.2/topics/i18n/ + +LANGUAGE_CODE = 'en-gb' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/penparse/penparse/urls.py b/penparse/penparse/urls.py new file mode 100644 index 0000000..711e4bf --- /dev/null +++ b/penparse/penparse/urls.py @@ -0,0 +1,25 @@ +""" +URL configuration for penparse project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.2/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.urls import include, path +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path("", include("webui.urls")), + path('admin/', admin.site.urls), + +] diff --git a/penparse/penparse/wsgi.py b/penparse/penparse/wsgi.py new file mode 100644 index 0000000..a40ab91 --- /dev/null +++ b/penparse/penparse/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for penparse 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.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'penparse.settings') + +application = get_wsgi_application() diff --git a/penparse/webui/__init__.py b/penparse/webui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/penparse/webui/admin.py b/penparse/webui/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/penparse/webui/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/penparse/webui/apps.py b/penparse/webui/apps.py new file mode 100644 index 0000000..79af5f3 --- /dev/null +++ b/penparse/webui/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WebuiConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'webui' diff --git a/penparse/webui/migrations/__init__.py b/penparse/webui/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/penparse/webui/models.py b/penparse/webui/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/penparse/webui/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/penparse/webui/tests.py b/penparse/webui/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/penparse/webui/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/penparse/webui/urls.py b/penparse/webui/urls.py new file mode 100644 index 0000000..5119061 --- /dev/null +++ b/penparse/webui/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.index, name="index"), +] diff --git a/penparse/webui/views.py b/penparse/webui/views.py new file mode 100644 index 0000000..1252696 --- /dev/null +++ b/penparse/webui/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render +from django.http import HttpResponse + + +def index(request): + return HttpResponse("Hello, world. You're at the polls index.") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8885187 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "penparse" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.9" +dependencies = [ + "django>=4.2.16", +] diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..06828c3 --- /dev/null +++ b/uv.lock @@ -0,0 +1,66 @@ +version = 1 +requires-python = ">=3.9" + +[[package]] +name = "asgiref" +version = "3.8.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/29/38/b3395cc9ad1b56d2ddac9970bc8f4141312dbaec28bc7c218b0dfafd0f42/asgiref-3.8.1.tar.gz", hash = "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590", size = 35186 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/e3/893e8757be2612e6c266d9bb58ad2e3651524b5b40cf56761e985a28b13e/asgiref-3.8.1-py3-none-any.whl", hash = "sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47", size = 23828 }, +] + +[[package]] +name = "django" +version = "4.2.16" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "asgiref" }, + { name = "sqlparse" }, + { name = "tzdata", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/65/d8/a607ee443b54a4db4ad28902328b906ae6218aa556fb9b3ac45c0bcb313d/Django-4.2.16.tar.gz", hash = "sha256:6f1616c2786c408ce86ab7e10f792b8f15742f7b7b7460243929cb371e7f1dad", size = 10436023 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/2c/6b6c7e493d5ea789416918658ebfa16be7a64c77610307497ed09a93c8c4/Django-4.2.16-py3-none-any.whl", hash = "sha256:1ddc333a16fc139fd253035a1606bb24261951bbc3a6ca256717fa06cc41a898", size = 7992936 }, +] + +[[package]] +name = "penparse" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "django" }, +] + +[package.metadata] +requires-dist = [{ name = "django", specifier = ">=4.2.16" }] + +[[package]] +name = "sqlparse" +version = "0.5.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/57/61/5bc3aff85dc5bf98291b37cf469dab74b3d0aef2dd88eade9070a200af05/sqlparse-0.5.2.tar.gz", hash = "sha256:9e37b35e16d1cc652a2545f0997c1deb23ea28fa1f3eefe609eee3063c3b105f", size = 84951 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7a/13/5f6654c9d915077fae255686ca6fa42095b62b7337e3e1aa9e82caa6f43a/sqlparse-0.5.2-py3-none-any.whl", hash = "sha256:e99bc85c78160918c3e1d9230834ab8d80fc06c59d03f8db2618f65f65dda55e", size = 44407 }, +] + +[[package]] +name = "typing-extensions" +version = "4.12.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/df/db/f35a00659bc03fec321ba8bce9420de607a1d37f8342eee1863174c69557/typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8", size = 85321 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", size = 37438 }, +] + +[[package]] +name = "tzdata" +version = "2024.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e1/34/943888654477a574a86a98e9896bae89c7aa15078ec29f490fef2f1e5384/tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc", size = 193282 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a6/ab/7e5f53c3b9d14972843a647d8d7a853969a58aecc7559cb3267302c94774/tzdata-2024.2-py2.py3-none-any.whl", hash = "sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd", size = 346586 }, +]