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.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"]
# urls.py — preferences API for AG-Grid
urlpatterns = [path("", include("django_grid_view.urls"))]
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 in the ContextUnity stack 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 the existing ContextUnit event channel (router → SSE → chat/dashboard hosts).

django-grid-view stays the single place that turns rows + spec → GridArtifact. Presenter and transport logic live in consumer apps and ContextUnity router work already tracked in platform planning.


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

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.0.1.tar.gz (66.0 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.0.1-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_grid_view-1.0.1.tar.gz
  • Upload date:
  • Size: 66.0 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.0.1.tar.gz
Algorithm Hash digest
SHA256 fabc9de25b781f1049ab95c7d5f90001699605ae825c21b84e538dc566a46782
MD5 ec5ca2ad84a979c63e0b070d75791371
BLAKE2b-256 5363f189d6ff07a5cc6475ba963c6731fbad87d48265b9fab715a47effc89435

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grid_view-1.0.1.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.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_grid_view-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a78090225dd1f8f4d4eb9b0c6c7c038cfae5e663c893e16b514e74dcd75505b
MD5 cef083936f403548bd370a7f1b438e36
BLAKE2b-256 5514f57411fcaefb54fe87fd42b59a05054009f6b55eb8a3824195babb649148

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grid_view-1.0.1-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