feat: Django project skeleton with pytest setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-05 13:46:53 +08:00
parent 1d2531a71f
commit f115a48c59
16 changed files with 149 additions and 0 deletions

0
src/config/__init__.py Normal file
View File

View File

@@ -0,0 +1 @@
from .base import * # noqa: F401,F403

View File

@@ -0,0 +1,58 @@
import os
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "dev-secret-key")
DEBUG = False
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split(",")
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"openclaw",
]
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",
],
},
},
]
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST": os.environ.get("DB_HOST", "localhost"),
"PORT": os.environ.get("DB_PORT", "5432"),
"NAME": os.environ.get("DB_NAME", "openclaw_archive"),
"USER": os.environ.get("DB_USER", "openclaw"),
"PASSWORD": os.environ.get("DB_PASSWORD", ""),
}
}
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
STATIC_URL = "static/"

View File

@@ -0,0 +1,13 @@
from pathlib import Path
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent.parent
from .base import * # noqa: F401,F403
DEBUG = True
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3", # noqa: F821
}
}

7
src/config/urls.py Normal file
View File

@@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("openclaw.urls")),
]

5
src/config/wsgi.py Normal file
View File

@@ -0,0 +1,5 @@
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
application = get_wsgi_application()

0
src/openclaw/__init__.py Normal file
View File

6
src/openclaw/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class OpenclawConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "openclaw"

3
src/openclaw/urls.py Normal file
View File

@@ -0,0 +1,3 @@
from django.urls import path
urlpatterns = []