Skip to main content

No project description provided

Project description

Generic Table

A Python package that provides features for managing and manipulating tables with:

  • Pagination
  • Filtering
  • Sorting
  • Excel Data Export

That provides the GenericTable frontend component with everything it needs.

📦 Installation

Install via pip

To install the package from PyPI, run the following command:

pip install generic-table

Usage

View Table Data with Pagination, Filtering, and Sorting

Use the view function to apply pagination, filtering, and sorting to a Django queryset. Here’s an example:

from myapp.models import WorkOrder
from generic_table import view  # Importing the view function from the package

def get_work_orders(request):
    # Get all work orders (simple queryset)
    qs = WorkOrder.objects.all()

    # Define the counted values for the 'status' field
    counted_values = ['IN_PROGRESS', 'APPROVED', 'CANCELLED', 'COMPLETED']

    # Use the `view` function from the `generic_table` package to return the response
    return view(
        qs,
        request,
        field="status",  # The field to count/filter by
        counted_values=counted_values,
        values_list=[
            "id", "status", "number", "description"
        ],  # Fields to return in the response
        data_key="workOrders",  # The key to map the data in the response
    )

2. Handling Excel Exports

You can also export table data to Excel. It looks for an Accept header with value of "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

from generic_table.generic_table import view
from myapp.models import MyModel

def export_data(request):
    queryset = MyModel.objects.all()
    field = 'status'
    counted_values = ['active', 'inactive']
    return view(queryset, request, field, counted_values, values_list=['status', 'id'])

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

generic_table-1.1.3.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

generic_table-1.1.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file generic_table-1.1.3.tar.gz.

File metadata

  • Download URL: generic_table-1.1.3.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for generic_table-1.1.3.tar.gz
Algorithm Hash digest
SHA256 751f19a548a0e93a54cdd46bfba9c466bc2f75c4d8d9fb1f4e6c732aa4361f87
MD5 9fc7c43f5c182b436b7b39c6ec93199b
BLAKE2b-256 95b0c86389a9b3c80c09f32096c748007cc6b179601d96169759cc30f08f6baf

See more details on using hashes here.

Provenance

The following attestation bundles were made for generic_table-1.1.3.tar.gz:

Publisher: publish.yml on TechServ-Consulting-Training-Ltd/generic-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 generic_table-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: generic_table-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for generic_table-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79b9fbef75597b90ff347b83ed27f0a02f628ee611d7a183b7c6ccd3e97fa657
MD5 1923c796e761b5ebdd838148f779c8c7
BLAKE2b-256 96d32acd66c8e1e915bfde9c170bb520a481ff340eb4cdc1c3bd8ef6dee4298a

See more details on using hashes here.

Provenance

The following attestation bundles were made for generic_table-1.1.3-py3-none-any.whl:

Publisher: publish.yml on TechServ-Consulting-Training-Ltd/generic-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