Skip to content

Modernise template: Django 6 / Python 3.14, security fixes, tests, docs & tooling - #19

Open
Serbel97 wants to merge 7 commits into
backbonesk:masterfrom
Serbel97:feature/template-modernization
Open

Modernise template: Django 6 / Python 3.14, security fixes, tests, docs & tooling#19
Serbel97 wants to merge 7 commits into
backbonesk:masterfrom
Serbel97:feature/template-modernization

Conversation

@Serbel97

Copy link
Copy Markdown
Member

Summary

Modernises the template (Django 6 / Python 3.14), fixes a number of correctness and deployment bugs, and adds a test suite, documentation site, tooling and a /ip proposal skill.

Upgrades

  • Django 6, Python 3.14, dependency bumps (django-filter, argon2-cffi, Black 25)
  • Standard PostgreSQL PG* environment variables (PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE)

Security & correctness fixes

  • BasicBackend base64 credential decode
  • Authorization on UserDetail (self-or-permission) + fixed inverted UserChecker
  • default_permissions now include view/change so core.view_user exists
  • order_by allow-list (Model.ORDERING_FIELDS) to prevent ordering injection
  • Token expiry computed at creation via TokenManager
  • CSRF middleware (API views csrf_exempt) + production hardening (HSTS, secure cookies, SSL redirect, ALLOWED_HOSTS/CSRF_TRUSTED_ORIGINS from env)
  • SECRET_KEY now required (ImproperlyConfigured if missing)

Deployment fixes

  • supervisor.conf uses the project WSGI module (was hard-coded veolia_api)
  • Aligned supervisord config path between Dockerfile and entrypoint
  • Fixed docker-compose.yml DB credentials, volumes and healthcheck

Admin & models

  • Django admin wired up (custom UserAdmin, ApiKey/Token/RecoveryCode), added is_staff
  • db_default on boolean/choice model fields

Observability & tooling

  • LOGGING config (console, LOG_LEVEL)
  • mypy + flake8 wired up with config; Makefile (run, test, lint, typecheck, migrations, docs)

Documentation

  • mkdocs-material site with the proposal (IP) system + .authors.yml
  • /ip skill for quick proposal capture
  • CLAUDE.md with project structure, code style, testing and the proposal workflow

Testing

  • Django unittest suite (46 tests) covering API views, services and database behaviour (soft-delete, token expiry, managers, ordering), with signed (X-Apikey + X-Signature) request helpers

Post-generation

  • hooks/post_gen_project.py generates .env with a fresh SECRET_KEY on project creation

Validation

Verified against a freshly rendered project on Postgres: makemigrations + migrate, 46 tests pass, flake8/mypy clean, manage.py check clean, dev server boots.

🤖 Generated with Claude Code

- Setup layered application structure under `apps/` (e.g., `api`, `core`, `tests`).
- Include templates for administration (`admin.py`), testing (`base.py`, `fixtures.py`), proposals (`.template.md`), and documentation (`mkdocs` with `docs/`).
- Configure project guidelines: linting (flake8), formatting (Black), type-checking (mypy), and proposal-first workflow.
- Introduce base test helpers (e.g., `Base` class with signed request logic).
- Add Makefile for streamlined development commands (`test`, `migrate`, `format`, etc.).
- Populate project with necessary configuration files for MkDocs, Flake8, and initial `.env` setup.
@Serbel97
Serbel97 requested review from Philliip, Sibyx and sopi20 June 23, 2026 17:04
@Serbel97 Serbel97 self-assigned this Jun 23, 2026
Comment thread {{cookiecutter.directory_name}}/docker-compose.yml Outdated
Comment thread {{cookiecutter.directory_name}}/CLAUDE.md
Comment thread {{cookiecutter.directory_name}}/CLAUDE.md Outdated
Comment thread {{cookiecutter.directory_name}}/.flake8
# Generate using: https://djecrety.ir/
SECRET_KEY=

EMAIL_IMAP_HOST=''

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

za mna by bolo pre uplnost fajn tuto pridat comment, ze tie EMAIL_IMAP sa tykaju iba cisto toho naseho django imap backendu, a pridat sem example aj pre klasicky smtp backend (kedze tie tu uplne chybaju, mozno okrem EMAIL_SENDER_NAME, ak ten sa tam pouziva)

Comment thread {{cookiecutter.directory_name}}/{{cookiecutter.project_name}}/settings/base.py Outdated
Comment thread {{cookiecutter.directory_name}}/docs/.authors.yml Outdated
Comment thread {{cookiecutter.directory_name}}/mkdocs.yml Outdated
Serbel97 added 2 commits June 24, 2026 16:40
- Drop `django.contrib.admin` from installed apps, URLs, and dependencies.
- Remove custom admin forms, models, and fieldsets from `apps.core.admin`.
- Adjust project settings and templates to align with the updated configuration.
- Update documentation and placeholders (`README.md`, `CLAUDE.md`, `.authors.yml`).
- Revert Redis image to version 6 for compatibility.
- Swap Redis for Valkey (a BSD-licensed alternative) to avoid restrictive licensing.
- Update `docker-compose.yml` with Valkey image and configurations.
- Add `REDIS_DB` to `.env.example` for improved flexibility.
Comment thread {{cookiecutter.directory_name}}/.env.example Outdated
- Remove HSTS mention from CHANGELOG for accuracy.
- Drop unused `REDIS_HOST` from `.env.example`.
PGPASSWORD=admin

REDIS_HOST=localhost
REDIS_DB=0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a toto nechces dat prec tiez ?

@Philliip
Philliip force-pushed the feature/template-modernization branch from 114d8d1 to 8175301 Compare July 5, 2026 15:39
Serbel97 added 2 commits July 6, 2026 09:42
- Enforce email normalization (`strip` and `lower`) in models, forms, and managers.
- Add database-level case-insensitive unique constraint for `email` field.
- Update user-related tests (`manager`, `views`, `db`) to validate expected behavior.
- Enhance email validation logic in registration and update forms.
- Refactor and expand tests to verify email handling during CRUD operations.
- Drop MkDocs-related dependencies, files, and configurations (`mkdocs-material`, `.authors.yml`, `mkdocs.yml`).
- Transition to a markdown-only proposal system under `docs/proposals/`.
- Update documentation and proposal guidelines in `CLAUDE.md` and `CHANGELOG`.
- Refactor base model to leverage `RandomUUID` and improve field defaults.
- Remove unused Makefile `docs` target and related build instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants