Skip to main content

As DataTables is a quite power and useful JavaScript library for manipulating and displaying data, we intended to make integration of the client-side DataTables scripts with the server-side processing based on Flask and peewee.

Installation

Note

As we have noticed, there’s already a Flask-DataTables library available on PyPI. However, this package was intended for integration with SQLAlchemy instead of peewee.

To start with, simply install the Flask-DataTables package from PyPI:

pip install Flask-DataTables-peewee

or should you prefer the bleeding edge version:

git clone https://github.com/JarryShaw/Flask-DataTables.git
cd Flask-DataTables
pip install .

Usage

Flask-DataTables is quite simple to use, just declare your data model in the preferable way from peewee and voilà, that’s it.

Taking examples from the peewee documentation, we can have a DataTables integrated data model just as below:

from flask import Flask
from flask_datatables import (CharField, DataTable, DateTimeField,
                              ForeignKeyField, Metadata, TextField)

DATABASE = 'postgresql://postgres:password@localhost:5432/my_database'

app = Flask(__name__)
app.config.from_object(__name__)

db_wrapper = DataTable(app)


class User(db_wrapper.Model):
    username = CharField(unique=True)

    class Meta(Metadata):
        datatables = True


class Tweet(db_wrapper.Model):
    user = ForeignKeyField(User, backref='tweets')
    content = TextField()
    timestamp = DateTimeField(default=datetime.datetime.now)

    class Meta(Metadata):
        datatables = True

And now, you may simply call Tweet.search() to perform the server-side processing queries.

See Also

It is also possible to customise the orderable and/or searchable fields through flask_datatables.fields.Field parameters, and their corresponding behaviours by subclassing the flask_datatables.fields.Field classes.

Release files for Flask-DataTables-peewee 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-DataTables-peewee 0.1.2
File Size Uploaded
Flask-DataTables-peewee-0.1.2.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-DataTables-peewee 0.1.2
File Interpreter ABI Platform
Flask_DataTables_peewee-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / Flask-DataTables-peewee-0.1.2.tar.gz

Download URL Flask-DataTables-peewee-0.1.2.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3a386113e1819db24f19090848e03581632496b8b9ced274186b5be0dfbbfcfc
BLAKE2b-256 checksum
How to use checksums
667aca9d79a8403a1f34b5c57965216592295610a7b377485ca114b6d2e99f7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

Release files / Flask_DataTables_peewee-0.1.2-py3-none-any.whl

Download URL Flask_DataTables_peewee-0.1.2-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62fc8154338d7fbc983e927b7a40aff78e6a96a8385dff6a170b24698df8bcac
BLAKE2b-256 checksum
How to use checksums
3a0c002e8ff4a59ede6561da83a39e9a4675193593f474bc8d293595999777a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page