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.5.tar.gz (20.6 kB view details)

Uploaded Source

Built Distributions

flask_datatables-0.6.5-py3.5.egg (48.2 kB view details)

Uploaded Source

flask_datatables-0.6.5-py3.4.egg (48.4 kB view details)

Uploaded Source

flask_datatables-0.6.5-py3.3.egg (48.9 kB view details)

Uploaded Source

flask_datatables-0.6.5-py3.2.egg (48.3 kB view details)

Uploaded Source

flask_datatables-0.6.5-py2.7.egg (47.6 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.5.tar.gz
Algorithm Hash digest
SHA256 b7df597156b7a8728165588686719438a8d66ccd43aad29150a80c42bb432c89
MD5 63646e2ac804bf0096878832bf3907a0
BLAKE2b-256 c44b9dc989894492e6d214a0656eab1375ff4d5b23279a22faf5a814d3f05fc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.5-py3.5.egg
Algorithm Hash digest
SHA256 07ccb1da0facb2f1dd54460007e3ce2c8e7d1a81ed7b5ddc61beb193ff098be6
MD5 05e8d1d89504d445160ad0eda80b1d0c
BLAKE2b-256 d2d5d5cf799dbc72bad496daacc779251d5c75e98da758543084797576a04802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.5-py3.4.egg
Algorithm Hash digest
SHA256 b1a466070d568e7ef2575432dda2fe285d7abe1732badf90f2ddb57525b50712
MD5 eb44ba8f03f2f8292ba5f92b2e6361e6
BLAKE2b-256 3d94ec29682b98333b970cbca10ec48c93a8459db8be4bcf6ad094eaec39a360

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.5-py3.3.egg
Algorithm Hash digest
SHA256 78f9825b04e0072d63918a57cf4c73991fc47301628d1e3b55cfcb6b8987217d
MD5 8e490364970e24e1a451553228554c56
BLAKE2b-256 4894927f246b59812aab07671b61dd9a11115c0d49b52a15dadbaea77772749a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.5-py3.2.egg
Algorithm Hash digest
SHA256 2526cb6130ba2f126f4eb66d3b7ceae4a9eca67610eba6ed3d62bcee346ed075
MD5 19096ce65fd45bbfd19c5ffec98d2b10
BLAKE2b-256 7320181066e3fa8ecab8811c87d98f2f8609671f55705ad20d6bd66669522262

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.5-py2.7.egg
Algorithm Hash digest
SHA256 153699b8a78bfd7bef78185af3d73666dfda315539cd0bf1f28ba7e845cf5c65
MD5 d9674be4aae39f3ef5a99b5aa8ac0c4e
BLAKE2b-256 00d8f2d427c9b779b3d84c4074cb3dc23eb458c670125258ed529bc6c09ca81f

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