Flask & peewee integration with DataTables server-side processing
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.
Metadata
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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| Flask-DataTables-peewee-0.1.2.tar.gz | 13.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|
Security for Flask-DataTables-peewee 0.1.2
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.