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

Uploaded Source

Built Distributions

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

Uploaded Source

flask_datatables-0.6.6-py3.4.egg (48.3 kB view details)

Uploaded Source

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

Uploaded Source

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

Uploaded Source

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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.6.tar.gz
Algorithm Hash digest
SHA256 c3a9802f35e4d87b5ec73f4717378a630390d9fdee56975b0e74cb6ef6158ccf
MD5 8871baa59a40036f8a7bd60b8722b9b8
BLAKE2b-256 0eff8fa37d9b3d0336f9d554fb3145c138782f44632b0226bbacb335ca73ab82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.6-py3.5.egg
Algorithm Hash digest
SHA256 13361681093439001bd9008bc601d34bf13a70778d8ecd56b93e0e54c21f7cb4
MD5 06c07e0455d6fa34639083490d78233e
BLAKE2b-256 372eff93c368ec32d933fe66d7266058a42f547de203307c0100de27a9dee0f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.6-py3.4.egg
Algorithm Hash digest
SHA256 96d327b8ff306df8cf57a5b5f336ca85f1ed096c82f7ea5bd0765a43f5ae4ae0
MD5 19835f30c3820bc7a29ba4cae89d5a35
BLAKE2b-256 190744b374d468e7cc805f8072d4a26a26da8368943c87963f1d3192eb8b61b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.6-py3.3.egg
Algorithm Hash digest
SHA256 211b9d293a7d0339b9adeeba509df051d51ae0b3241f5494ffc439a715aee7b7
MD5 c33aaaccb949738f414e5927ec171c53
BLAKE2b-256 5c0d83d84841621edad6d8ca02ec9c52792185eebeb16f7f864a08c62397ba4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.6-py3.2.egg
Algorithm Hash digest
SHA256 d39324e26502bf55aed781520d71e4e29745bf6a08b19d7e1bac83d6eb548b53
MD5 5f236c6d5e2e34bd54e5e92961697359
BLAKE2b-256 3e1c09d58e197c840c86b85223cb9abe27b294970179452840b0bd1df664021d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_datatables-0.6.6-py2.7.egg
Algorithm Hash digest
SHA256 f501e46569258c3b512b79f9d9e28cf53dbeeda22a85e0792603c80d85d18dcf
MD5 fd27cbf9e36c20db761b30cd29d1181b
BLAKE2b-256 9c371265da7742e05175a90d89c49c619942a55a7c076a57a53475cc0e1a4408

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