Skip to main content

Integrates SQLAlchemy with DataTables (framework Flask)

Project description

====================
Flask-restful only version of orf/datatables with Flask-restless style filtering
====================

Additional Functionality
------------
One thing I needed to do so that this would support our needs internally is
to support arbitrary join depth to be able to do search and sort functionality
on the results. With Orf's version, I was only able to order by or search on 2
levels deep of a query result. Now that level is arbitrary such that you can
provide a column on say a Subnet table that is associated with a location
through relations like subnet.vlan.switch.rack.location and make the location name
filterable AND orderable with just "vlan__switch__rack__location__name"

Installation
------------

The package is available on PyPI and is passing tests on Python 2.7, 3.3 and 3.4
Working on getting this on PyPI

.. code-block:: bash

pip install flask_datatables

Usage
-----


This is SUPER simple. In datatables I provide a function called get_resource that can be used to create a
datatables api endpoint with full flask-restless style filtering built in.


Additional data such as hyperlinks can be added via DataTable.add_data, which accepts a callable that is called for
each instance. Check out the usage example below for more info.


Example
-------

**models.py**

.. code-block:: python

class User(Base):
__tablename__ = 'users'

id = Column(Integer, primary_key=True)
full_name = Column(Text)
created_at = Column(DateTime, default=datetime.datetime.utcnow)



class Address(Base):
__tablename__ = 'addresses'

id = Column(Integer, primary_key=True)
description = Column(Text)
user_id = Column(Integer, ForeignKey('users.id'))

user = relationship("User", backref=backref("address", uselist=False))

def __repr__(self):
return "{}".format(self.description)


**api.py**

.. code-block:: python

from model import Session, User, Address
from datatables import *

app = Flask(__name__)
api = Api(app)
# add User resource
resource, path, endpoint = get_resource(Resource, User, Session, basepath="/")
api.add_resource(resource, path, endpoint=endpoint)

# add Address resource
resource, path, endpoint = get_resource(Resource, Address, Session, basepath="/")
api.add_resource(resource, path, endpoint=endpoint)

if __name__ == '__main__':
app.run(host='127.0.0.1', port=5001, debug=True)

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

flask_datatables-0.6.10.tar.gz (20.7 kB view details)

Uploaded Source

Built Distributions

flask_datatables-0.6.10-py3.5.egg (48.5 kB view details)

Uploaded Source

flask_datatables-0.6.10-py3.4.egg (48.6 kB view details)

Uploaded Source

flask_datatables-0.6.10-py3.3.egg (49.1 kB view details)

Uploaded Source

flask_datatables-0.6.10-py3.2.egg (48.5 kB view details)

Uploaded Source

flask_datatables-0.6.10-py2.7.egg (47.8 kB view details)

Uploaded Source

File details

Details for the file flask_datatables-0.6.10.tar.gz.

File metadata

File hashes

Hashes for flask_datatables-0.6.10.tar.gz
Algorithm Hash digest
SHA256 98a7055fcbac3fe025c4832bbbc5dc6ba622f669757e5f1ff26381a330693daf
MD5 80edfde9070a97897205ecda62253d60
BLAKE2b-256 6842fe80029b46a14eb83a3f3bcac3784442ce50336c6539efd375e194af4c81

See more details on using hashes here.

File details

Details for the file flask_datatables-0.6.10-py3.5.egg.

File metadata

File hashes

Hashes for flask_datatables-0.6.10-py3.5.egg
Algorithm Hash digest
SHA256 b3a8d51025a82d3e2c4bdacbc3c44f2a329879cbad77b53ea927e39f9b932af6
MD5 8af3b2fb7a82eb6996fa41930cb5ccb2
BLAKE2b-256 af610645a3582437afdd9be096974d19e1ac7e58c8a731bd5cc4900210e52d21

See more details on using hashes here.

File details

Details for the file flask_datatables-0.6.10-py3.4.egg.

File metadata

File hashes

Hashes for flask_datatables-0.6.10-py3.4.egg
Algorithm Hash digest
SHA256 fa6a9561aba8b1aeba828d4a2392f1bd5a94d51dbeaedc6add3694371ac64201
MD5 96918b14acf4506afc4b54beb0fd699e
BLAKE2b-256 4f1f049dc8d378e72332364d6c9fc1717c36cd4040d7cc3d99800c45d703c217

See more details on using hashes here.

File details

Details for the file flask_datatables-0.6.10-py3.3.egg.

File metadata

File hashes

Hashes for flask_datatables-0.6.10-py3.3.egg
Algorithm Hash digest
SHA256 90337cce744718ea35e8fe9de29cfae8080a6b9f6bc724e8dcb6b467aaf8b00e
MD5 1861885dc0cb0e04dbb5c32cfba42360
BLAKE2b-256 61136f62d61b3d075b2dc5f6602036c62c0da3005d0e1928c9b98b7746d28467

See more details on using hashes here.

File details

Details for the file flask_datatables-0.6.10-py3.2.egg.

File metadata

File hashes

Hashes for flask_datatables-0.6.10-py3.2.egg
Algorithm Hash digest
SHA256 7ab39ea196560c917a3dcaffece80b1494ac91ff468901fc85f962a53c40ef35
MD5 45f91ddce403f034e09e224ac2088a9b
BLAKE2b-256 4045014480a3eca39bd7aab7f759ca99198f8f7388ebd1046aa9ab7142ddf9b1

See more details on using hashes here.

File details

Details for the file flask_datatables-0.6.10-py2.7.egg.

File metadata

File hashes

Hashes for flask_datatables-0.6.10-py2.7.egg
Algorithm Hash digest
SHA256 a313ec0cfbce27a39d05f34c91f387f16d9b9727ddbf10bfcb490a0599ea6c0d
MD5 6fd265d6da1839968ec2ec7896a8cb5e
BLAKE2b-256 0c57e4e8fea1df6ce690d86754259c1ef45c03a9d7d83940ed18fe6bebd6e497

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page