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

Uploaded Source

Built Distributions

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

Uploaded Source

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

Uploaded Source

flask_datatables-0.6.9-py3.3.egg (49.2 kB view details)

Uploaded Source

flask_datatables-0.6.9-py3.2.egg (48.6 kB view details)

Uploaded Source

flask_datatables-0.6.9-py2.7.egg (47.9 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.9.tar.gz
Algorithm Hash digest
SHA256 7e838c1a6ece1c1680d855f5ed680ec0321972e7393ab0ed0e880a1821f3f01a
MD5 6fa61d9f419d4e46fab07793bab8d7df
BLAKE2b-256 1b237f76bcbf49ab9a0604f8283f34b5ed821948472e5e2e98bb95128fe69a1b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.9-py3.5.egg
Algorithm Hash digest
SHA256 65637be5aa3a3782ae753a59deba844a948fcacde36c4c9e74e98a8286b60d25
MD5 90cebb0545d4d7730558af74c5d53c5d
BLAKE2b-256 22a1dd37fad7e12ba4b8d3b7d1656c8a19e04ae593077a37089f98b6fed002c0

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.9-py3.4.egg
Algorithm Hash digest
SHA256 a42da7686f1330eb2ccdd99a44e0bc5f2ce4fbe0a50353c32da36de86a29b7a8
MD5 2cd7bd5cc616531e9bb74e827cdb75d4
BLAKE2b-256 65b6d561b6bf29c287eb49950be228fa224a17f1b46f176402594ab9652a8557

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.9-py3.3.egg
Algorithm Hash digest
SHA256 701ecdcbbe3460502cf05dcfd1392f99ee391abce9d04320ca8e94b280f0cd96
MD5 ffc06b898162e9e909774b4f2b137dfa
BLAKE2b-256 fc83123a61e4c3e2f9c18ac77dd166c79d81f434eecbabfe24791a38a15fdad6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.9-py3.2.egg
Algorithm Hash digest
SHA256 69f6bff1697bf25a04fbc25ee0de87f8b8d7f6538b3df9ee099092d94baf0337
MD5 e6f4ca32b429dbd8a24912905860a8dc
BLAKE2b-256 011540882941b686010e216c93af052bfd5592387965c6898283b30753b95f56

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.9-py2.7.egg
Algorithm Hash digest
SHA256 110ecbbf422e46097d84cfae436136018af3f82c6bfcf332eeab9756f6bb635b
MD5 97f7d33c5e175aa0774312c2a8576797
BLAKE2b-256 e51e254153d195a3469c2fbe900144ec4ffffc355923225540b42a9b0f08e7b2

See more details on using hashes here.

Provenance

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