From 265d54050c3177b5cd9f0716df07c90309b13a1b Mon Sep 17 00:00:00 2001 From: Stephan Kerkman Date: Wed, 27 May 2026 19:40:58 +0200 Subject: [PATCH] feat: scaffold Django project with plants app Co-Authored-By: Claude Sonnet 4.6 --- .env.example | 4 ++ .gitignore | 8 ++++ manage.py | 22 +++++++++++ plantdb/__init__.py | 0 plantdb/asgi.py | 16 ++++++++ plantdb/settings.py | 72 +++++++++++++++++++++++++++++++++++ plantdb/urls.py | 22 +++++++++++ plantdb/wsgi.py | 16 ++++++++ plants/__init__.py | 0 plants/admin.py | 3 ++ plants/apps.py | 6 +++ plants/migrations/__init__.py | 0 plants/models.py | 3 ++ plants/tests.py | 3 ++ plants/views.py | 3 ++ pytest.ini | 2 + requirements.txt | 17 +++++++++ 17 files changed, 197 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100755 manage.py create mode 100644 plantdb/__init__.py create mode 100644 plantdb/asgi.py create mode 100644 plantdb/settings.py create mode 100644 plantdb/urls.py create mode 100644 plantdb/wsgi.py create mode 100644 plants/__init__.py create mode 100644 plants/admin.py create mode 100644 plants/apps.py create mode 100644 plants/migrations/__init__.py create mode 100644 plants/models.py create mode 100644 plants/tests.py create mode 100644 plants/views.py create mode 100644 pytest.ini create mode 100644 requirements.txt diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..457390a --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +SECRET_KEY=change-me-in-production +DEBUG=False +ALLOWED_HOSTS=192.168.1.100,plantdb.home +PERENUAL_API_KEY=your-perenual-key-here diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..460ea17 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.venv/ +__pycache__/ +*.pyc +db.sqlite3 +media/ +staticfiles/ +.env +.superpowers/ diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..6f3a801 --- /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', 'plantdb.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/plantdb/__init__.py b/plantdb/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plantdb/asgi.py b/plantdb/asgi.py new file mode 100644 index 0000000..650a4df --- /dev/null +++ b/plantdb/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for plantdb 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/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'plantdb.settings') + +application = get_asgi_application() diff --git a/plantdb/settings.py b/plantdb/settings.py new file mode 100644 index 0000000..fa8854e --- /dev/null +++ b/plantdb/settings.py @@ -0,0 +1,72 @@ +import os +from pathlib import Path + +BASE_DIR = Path(__file__).resolve().parent.parent + +SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-change-in-production') +DEBUG = os.environ.get('DEBUG', 'True') == 'True' +ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',') + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django_htmx', + 'plants', +] + +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', + 'django_htmx.middleware.HtmxMiddleware', +] + +ROOT_URLCONF = 'plantdb.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 = 'plantdb.wsgi.application' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + +LANGUAGE_CODE = 'en-us' +TIME_ZONE = 'Europe/Amsterdam' +USE_I18N = True +USE_TZ = True + +STATIC_URL = '/static/' +STATIC_ROOT = BASE_DIR / 'staticfiles' + +MEDIA_URL = '/media/' +MEDIA_ROOT = BASE_DIR / 'media' + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +PERENUAL_API_KEY = os.environ.get('PERENUAL_API_KEY', '') diff --git a/plantdb/urls.py b/plantdb/urls.py new file mode 100644 index 0000000..153b887 --- /dev/null +++ b/plantdb/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for plantdb project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.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/plantdb/wsgi.py b/plantdb/wsgi.py new file mode 100644 index 0000000..51d3f27 --- /dev/null +++ b/plantdb/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for plantdb 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/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'plantdb.settings') + +application = get_wsgi_application() diff --git a/plants/__init__.py b/plants/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plants/admin.py b/plants/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/plants/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/plants/apps.py b/plants/apps.py new file mode 100644 index 0000000..90a2903 --- /dev/null +++ b/plants/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PlantsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'plants' diff --git a/plants/migrations/__init__.py b/plants/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/plants/models.py b/plants/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/plants/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/plants/tests.py b/plants/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/plants/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/plants/views.py b/plants/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/plants/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..991009f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE = plantdb.settings diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ce0b17c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +asgiref==3.11.1 +certifi==2026.5.20 +charset-normalizer==3.4.7 +Django==5.1.15 +django-htmx==1.27.0 +gunicorn==26.0.0 +idna==3.16 +iniconfig==2.3.0 +packaging==26.2 +pillow==12.2.0 +pluggy==1.6.0 +Pygments==2.20.0 +pytest==9.0.3 +pytest-django==4.12.0 +requests==2.34.2 +sqlparse==0.5.5 +urllib3==2.7.0