django-db-side-computation

Installation
SKILL.md

Django DB-Side Computation

Use this skill when Django fetches rows into Python to compute values the database can compute more efficiently or more consistently.

Workflow

  1. Identify the Python computation.

    • Counts, sums, min/max, booleans, latest related rows, rankings, denormalized totals, or per-row derived fields.
    • Confirm whether the computed value must be exact, current, and transactionally consistent.
  2. Pick the SQL expression level.

    • filter(), exclude(), and F() for simple comparisons and updates.
    • annotate() and aggregates for per-object counts and totals.
    • Filtered aggregates for conditional counts and sums.
    • Exists() for yes/no related-row checks.
    • Subquery() with OuterRef() for latest or scalar related values.
    • Window() for ranks and running calculations.
    • GeneratedField for deterministic same-row computed columns when the database supports it.
Installs
46
Repository
lvtd-llc/skills
GitHub Stars
1
First Seen
Jun 21, 2026
django-db-side-computation — lvtd-llc/skills