MUI Data Grid
This is an unofficial toolbox to make integrating a Python web application with Material UI's data grid simpler.
Documentation
Requirements
- Python 3.9.0+
Features
- Grid Sort Model support
- Grid Filter Model support (partial: missing quick filter support)
- Grid Pagination Model support (LIMIT / OFFSET based, cursor not currently supported)
- Flask integration
- SQLAlchemy integration
Installation
Pip
python -m pip install -U 'mui-data-grid'
or with extras:
python -m pip install -U 'mui-data-grid[flask]'
python -m pip install -U 'mui-data-grid[sqlalchemy]'
python -m pip install -U 'mui-data-grid[flask, sqlalchemy]'
Poetry
poetry add mui-data-grid
Usage
Integrations
Flask
#!/usr/bin/env python
# examples/main.py
from flask import Flask, jsonify
from flask.wrappers import Response
from mui.v5.integrations.flask import get_grid_models_from_request
# for v6 support, replace this import with:
# from mui.v6.integrations.flask import get_grid_models_from_request
app = Flask(__name__)
FILTER_MODEL_KEY = "filter_model"
SORT_MODEL_KEY = "sort_model[]"
PAGINATION_MODEL_KEY = None # stored inline in the query string, not encoded as an obj
@app.route("/")
def print_sorted_details() -> Response:
# models will return default values if the keys don't exist,
# so you can choose what features you integrate, and when.
models = get_grid_models_from_request(
filter_model_key=FILTER_MODEL_KEY,
pagination_model_key=PAGINATION_MODEL_KEY,
sort_model_key=SORT_MODEL_KEY,
)
return jsonify(
{
# sort_model is a list[GridSortItem]
SORT_MODEL_KEY: [model.model_dump() for model in models.sort_model],
# filter_model is GridFilterModel
FILTER_MODEL_KEY: models.filter_model.model_dump(),
# pagination_model is a GridPaginationModel
# providing a consistent interface to pagination parameters
PAGINATION_MODEL_KEY: models.pagination_model,
}
)
if __name__ == "__main__":
app.run()
SQLAlchemy
# please see examples/main.py for the full code
models = get_grid_models_from_request(
filter_model_key=FILTER_MODEL_KEY,
pagination_model_key=PAGINATION_MODEL_KEY,
sort_model_key=SORT_MODEL_KEY,
)
session = Session()
try:
base_query = session.query(ExampleModel)
dg_query = apply_request_grid_models_to_query(
query=base_query,
request_model=models,
column_resolver=example_model_resolver,
)
# we calculate total separately so that we can reuse the result
# rather than have .pages() fire off an additional db query.
total = dg_query.total()
def item_factory(item: ExampleModel) -> Dict[str, int]:
return item.model_dump()
return jsonify(
{
"items": dg_query.items(factory=item_factory),
"page": dg_query.page,
"pageSize": dg_query.page_size,
"pages": dg_query.pages(total=total),
"total": total,
}
)
finally:
session.close()
Metadata
Release files for mui-data-grid 0.15.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mui_data_grid-0.15.0.tar.gz | 38.8 kB | Without provenance | Details for mui_data_grid-0.15.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mui_data_grid-0.15.0-py3-none-any.whl | Python 3 | none | any | Details for mui_data_grid-0.15.0-py3-none-any.whl |
Total release size: 124.7 kB
Release files / mui_data_grid-0.15.0.tar.gz
| Download URL | mui_data_grid-0.15.0.tar.gz |
|---|---|
| Size | 38.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d396d91dea076c6876b526be2e99b09021e0dde70ffeea73ae2fde52f756efd
|
|
BLAKE2b-256 checksum How to use checksums |
5c2304de0a9187e540d2f5016a08c6e39dfbe686ceda85cbcd39f0ac32d65898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0
|
Release files / mui_data_grid-0.15.0-py3-none-any.whl
| Download URL | mui_data_grid-0.15.0-py3-none-any.whl |
|---|---|
| Size | 86.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
020b09d44e40474728a3edbe944cbf725d9602f35fa6c61e4859eb5f8dc2ece6
|
|
BLAKE2b-256 checksum How to use checksums |
9c1bb9c61a32203e5ad14efb4bbb9fd3f7a51fa5e96f330b5901281eb919d02e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0
|
Security for mui-data-grid 0.15.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.