Skip to main content

Reusable AG Grid integration for Django with HTMX-safe lifecycle and persisted grid preferences

Project description

Django Grid Table

Reusable Django app for AG Grid integrations with HTMX-safe lifecycle handling, saved searches, column presets, server-side grid preferences, and optional UI plugins.

Install:

pip install django-grid-table

Local editable install:

pip install -e ~/Projects/django-grid-table

With uv, keep the normal PyPI dependency and override it locally:

[project]
dependencies = [
    "django-grid-table>=0.1.0",
]

[tool.uv.sources]
django-grid-table = { path = "../django-grid-table", editable = true }

Django Setup

INSTALLED_APPS = [
    # ...
    "django_grid_table",
]
from django.urls import include, path

urlpatterns = [
    path("", include("django_grid_table.urls")),
]
python manage.py migrate django_grid_table

Template Usage

Load AG Grid and Sortable once in the base template, outside HTMX-swapped content:

<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@31.3.2/dist/ag-grid-community.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>

Use the bundled tag:

{% load django_grid_table %}

<div id="products-grid" class="ag-theme-quartz-dark"></div>

<script>
  window.ProductsGrid = {
    columnDefs: ProductColumns,
    rowModelType: "infinite",
    cacheBlockSize: 200,
    context: { gridId: "products" },
  };
</script>

{% django_grid_table_scripts grid_id="products" options_var="ProductsGrid" container_id="products-grid" %}

Or include partials directly:

{% include "django_grid_table/search_bar.html" with grid_id="products" %}
{% include "django_grid_table/modal.html" with grid_id="products" %}
{% include "django_grid_table/scripts.html" with grid_id="products" container_id="products-grid" options_var="ProductsGrid" %}

Optional plugins:

{% include "django_grid_table/plugins/smart_filter.html" %}
{% include "django_grid_table/plugins/advanced_search.html" %}
{% include "django_grid_table/plugins/custom_tooltip.html" %}

Runtime Rules

Do not load AG Grid CDN scripts inside HTMX-swapped fragments.

For AG Grid infinite row model, do not use quickFilterText or autoHeight. Use manager._searchText and backend filtering instead.

Always populate columnDefs before django_grid_table/scripts.html initializes the grid.

Development

uv sync --extra dev
uv run ruff check .
uv run pytest
uv build
uv run --with twine twine check dist/*

Release

Publishing uses GitHub Actions trusted publishing. Configure the PyPI project django-grid-table to trust the repository environment named pypi, then push a version tag:

git tag v0.1.0
git push origin v0.1.0

License

MIT

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_table-0.1.0.tar.gz (24.8 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_table-0.1.0-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file django_grid_table-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for django_grid_table-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54bea4ebe47cb3d9c90da005d72f300bcb2e0c0a5849a05b98461a5b9ab96817
MD5 74cdc25797c00a712c64cb499714e59d
BLAKE2b-256 1bd5450f043787b3afa744abbd27938fc8efb4a2182e7eb71f82e1fb21b99cb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grid_table-0.1.0.tar.gz:

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

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_table-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_grid_table-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29372c58a586c42400e47e8b11b7e359badccc3c083bf14963c9e89cd879a5f4
MD5 0d3c0e20e409ca0fd9d8f918c109f77f
BLAKE2b-256 bd0e5a5c90e5ae3773c91e94cf5c558fd0e6ce60f95777bf4b03ad8b2b55c589

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grid_table-0.1.0-py3-none-any.whl:

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

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