Skip to main content

Declarative GridViewSpec pages: tables, filters, KPI, charts, PDF/XLSX export; optional Django backend

Project description

Grid View Spec

PyPI Python Docs License: MIT

Declarative dashboard pages for Django and other hosts — tables, filters, KPI strips, charts, and export from one typed GridViewSpec contract. You own SQL/ORM rows; the package owns layout, templates, browser runtime, and PDF/XLSX pipelines.

Documentation · MCP server · PyPI


Core idea

Layer Owner
Data Host — querysets, aggregates, authorization
Spec GridViewSpec — blocks (GridViewTable, GridViewFilters, …) + layout
Render Package — Jinja/Django HTML, gridviewspec.min.js, export
from grid_view_spec import GridViewSpec, validate_spec
from grid_view_spec.types.layout import GridViewArea, GridViewLayout
from grid_view_spec.types.table_v2 import GridViewColumn, GridViewTable

spec = GridViewSpec(
    id="orders",
    blocks=(
        GridViewTable(
            id="orders_table",
            backend="simple",
            columns=(
                GridViewColumn(id="name", label="Customer", field="name"),
                GridViewColumn(id="amount", label="Amount", field="amount", type="currency"),
            ),
        ),
    ),
    layout=GridViewLayout(root=GridViewArea(id="root", blocks=("orders_table",))),
)
validate_spec(spec)
{% load grid_view_spec %}
{% grid_view_spec_assets part='css' %}
{% render_grid_view_spec spec rows %}
{% grid_view_spec_assets part='js' force_core=True %}

Install

pip install "grid-view-spec[django]"
# optional:
pip install "grid-view-spec[django,pdf,xlsx,mcp]"

Django

INSTALLED_APPS = ["grid_view_spec.backends.django"]
python manage.py migrate grid_view_spec_django
urlpatterns = [
    path("", include("grid_view_spec.backends.django.urls")),
]

See Getting started and Django integration.


Export

Register builders that return GridViewExportJob(spec, rows, table_id=…):

from grid_view_spec.export.registry import register_pdf_export, register_xlsx_export
from grid_view_spec.export.registry import GridViewExportJob

def register_exports():
    def builder(host, ctx):
        page = load_orders_page(ctx)  # same loader as HTML view
        return GridViewExportJob(spec=page.spec, rows=page.rows, table_id="orders_table")

    register_pdf_export("orders", builder)
    register_xlsx_export("orders", builder)

Browser links use ?builder=orders plus current filter query params. Details: Export page pattern.


AG-Grid, charts, MCP

  • AG-GridGridViewTable(backend="ag_grid") + host JSON API; helpers in grid_view_spec.backends.django.ag_grid
  • Charts / KPI — spec blocks + ECharts; values always from host rows
  • MCPgridviewspec-mcp for validation, catalog, migration hints (tools/mcp-server.md)

Development

uv sync
uv run pytest -q
uv run basedpyright --warnings src/grid_view_spec tests
cd frontend && npm run build && npm run typecheck

Pre-commit hooks: ruff, basedpyright, frontend typecheck/eslint, pytest.


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

grid_view_spec-2.0.0.tar.gz (759.8 kB view details)

Uploaded Source

Built Distribution

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

grid_view_spec-2.0.0-py3-none-any.whl (788.1 kB view details)

Uploaded Python 3

File details

Details for the file grid_view_spec-2.0.0.tar.gz.

File metadata

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

File hashes

Hashes for grid_view_spec-2.0.0.tar.gz
Algorithm Hash digest
SHA256 095727806253422d79d10fb98c690b06c72851e00a3892cc4639bc3a10ee4af6
MD5 39284fdc38b4e798cbbb43e97614ee0d
BLAKE2b-256 d5febb53f8e36c702c0e4abd3c67e684e684056b793ccca49408350fc2c80552

See more details on using hashes here.

Provenance

The following attestation bundles were made for grid_view_spec-2.0.0.tar.gz:

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

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

File details

Details for the file grid_view_spec-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: grid_view_spec-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 788.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grid_view_spec-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 368bb0bd19192be309347fb071ead0ca34f09892eb1c2d3c6a87d386d291f0be
MD5 6263f4c695a8e8a1c170f6954e6c822e
BLAKE2b-256 41f2cc6048fa7ef237a548011874e09d8239d34d2d4e74ce616a692dd96973a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for grid_view_spec-2.0.0-py3-none-any.whl:

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

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