Skip to main content

Declarative grid views for Django: Simple Table, AG-Grid helpers, KPI cards, ECharts, and an LLM-friendly GridViewSpec contract

Project description

Django Grid View

PyPI Python CI Docs License: MIT

Declarative grid views for Django — server tables, AG-Grid dashboards, KPI strips, and ECharts from one typed package. You own the data (rows from SQL/ORM); the library owns layout, formatting, and front-end wiring.

Documentation · LLM context bundle · PyPI


Why this package

Building dashboards and chat analytics in Django usually means stitching together three different stacks: hand-rolled HTML tables, AG-Grid boilerplate, and ad‑hoc chart JSON. django-grid-view unifies them behind a single contract:

Principle What it means for you
Structure ≠ data Specs (GridViewSpec, wire JSON) describe columns, KPIs, and charts — never row values or aggregates from an LLM.
One render path GridRenderer.build(spec, rows)GridArtifact → templates + grid-view.min.js. No parallel chart/table code paths.
Typed boundaries py.typed, strict-friendly django_grid_view.types, JSON Schema for wire specs — host apps keep pyright/mypy honest.
Production habits HTMX-safe AG-Grid lifecycle, saved grid preferences, uk/en i18n, optional matplotlib PNG export for PDFs.

What you get

Simple Table

Server-rendered tables with sort, search, CSV/XLSX export, grouped headers — no SPA required.

from django_grid_view.tables import Column, SimpleTableConfig

config = SimpleTableConfig(
    grid_id="products",
    columns=[Column(key="sku", label="SKU"), Column(key="name", label="Name")],
    data=rows,
)
{% load django_grid_view %}
{% render_simple_table config %}

AG-Grid helpers

Scripts, toolbar, advanced search plugins, and GridPreference storage for large or infinite grids. The package does not own your gridApi — you keep control of the grid instance; we supply the integration layer.

Grid View — KPI, charts, and table together

One GridViewSpec drives KPI cards, ECharts blocks, and tabular layout. Ideal for dashboard pages and chat “visualizer” UIs fed by analytics SQL.

from django_grid_view import GridViewSpec, RowDict, build_artifact_from_view
from django_grid_view.types import ColumnSpec, KpiSpec, KpiAggregate

artifact = build_artifact_from_view(
    {
        "grid_id": "overview",
        "columns": [{"key": "name", "label": "Name"}],
        "kpis": [{"label": "Total", "column_key": "amount", "aggregate": "sum"}],
    },
    rows,
)
{% grid_view_bundle %}
{% render_grid_view artifact %}

Install

pip install django-grid-view
# optional: static chart PNG export for PDF pipelines
pip install "django-grid-view[static-charts]"
# settings.py
INSTALLED_APPS = ["django_grid_view"]
# settings.py
DJANGO_GRID_VIEW_EXPORT_PDF_URL = "api_export_pdf"
DJANGO_GRID_VIEW_EXPORT_XLSX_URL = "api_export_xlsx"

# api/urls.py — mount under path("api/", include(...))
from django_grid_view.export.pdf_view import export_pdf
from django_grid_view.export.xlsx_view import export_xlsx
from django_grid_view.views import save_grid_settings

urlpatterns = [
    path("grid/preferences/", save_grid_settings, name="api_grid_preferences"),
    path("export/pdf/", export_pdf, name="api_export_pdf"),
    path("export/xlsx/", export_xlsx, name="api_export_xlsx"),
]
python manage.py migrate django_grid_view

Full walkthrough: Getting started.


Documentation

Topic Link
Simple Table Guide
AG-Grid + HTMX Guide
KPI & ECharts Guide
GridViewSpec → artifact Grid View artifacts
Python types for host apps Reference
JSON Schema (wire) schema/grid-view-spec.v1.json
Agents & coding tools LLM bundle · Agent skill
Changelog 1.0.0 notes

Roadmap — A2UI & AG-UI

1.0 (shipped) is the renderer: tables, KPI strip, ECharts, i18n, and GridRenderer in this repo.

Next step for host applications is protocol alignment, not replacing the renderer:

  • A2UI — treat GridViewSpec as the declarative UI catalog (structure-only JSON agents and planners emit).
  • AG-UI — stream resolved grid_view artifacts over an application event channel (router, SSE, chat, dashboard, or another host transport).

django-grid-view stays the single place that turns rows + spec → GridArtifact. Presenter and transport logic live in consumer apps.


Development

Requires uv. CI uses uv sync --frozen --group dev.

Install git hooks (strips Co-authored-by: Cursor from commit messages):

./scripts/install-git-hooks.sh
uv sync --group dev
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run basedpyright --warnings src/django_grid_view tests
./scripts/docs_serve.sh   # MkDocs + LLM bundle

JavaScript (maintainers only)

Browser bundles are built from TypeScript in frontend/src/ and written to src/django_grid_view/static/django_grid_view/ (.js + .min.js). PyPI consumers do not need Node — the wheel ships pre-built static files.

frontend/src/
  grid-view-entry.ts      # esbuild entry (IIFE bundle → grid-view.js)
  grid-view/              # modules: charts, kpi, filter-bar, search/, …
  column-settings.ts
  types/                  # chart-bind, kpi-bind (mirror Python contracts)
cd frontend && npm ci && npm run build   # transpile + minify
npm run typecheck && npm run lint        # strict types on search/ + contracts; eslint on all src/
npm run test:conformance                 # Python↔JS filter/search parity (shared JSON fixtures)

After editing frontend/src/*.ts, commit the regenerated static artifacts (CI verifies git diff --exit-code src/django_grid_view/static/).

Load order for host pages: {% grid_view_bundle %} once → grid-view.min.js + column-settings.min.js. AG-Grid pages add scripts.html partials. Details: Architecture · JavaScript API.

Release: tag v* on main → PyPI via trusted publishing (environment: pypi). Docs deploy from main via GitHub Actions.


License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_grid_view-1.2.0.tar.gz (219.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_grid_view-1.2.0-py3-none-any.whl (246.0 kB view details)

Uploaded Python 3

File details

Details for the file django_grid_view-1.2.0.tar.gz.

File metadata

  • Download URL: django_grid_view-1.2.0.tar.gz
  • Upload date:
  • Size: 219.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_grid_view-1.2.0.tar.gz
Algorithm Hash digest
SHA256 365fd646cfed4f1baf00c1c3d36cbaeb48ccdc9c81a1cea85d6401f1cb208c5e
MD5 7688177cc6fe86fbb84bbd309ce66072
BLAKE2b-256 a7979d0eff6f255d02e954b86b75762dc99d1e35cd5215ff533a1b175791c14b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grid_view-1.2.0.tar.gz:

Publisher: ci.yml on alpiua/django-grid-view

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_grid_view-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_grid_view-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d7c8431776b7968c50b58beab7a5bc3850abdaeeaa5a93945db4b28a87748c3
MD5 db289269641212afa52e16c01e367831
BLAKE2b-256 a135098ab5c016605cc8f3029dd60bb767f2af3fe37b5c3225b882dde201db7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grid_view-1.2.0-py3-none-any.whl:

Publisher: ci.yml on alpiua/django-grid-view

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page