Skip to main content

Server side code to expose a datamodel for the flask-restless client

Project description

Build Status Codecov PyPI version


This library is one part of a two part piece of code. It fulfills the server part to the flask-restless client. What it does is allow you to render your datamodel in a convenient JSON format. This JSON format is then read by the flask-restless-client, which in turn uses it to built itself, allowing for transparent access to your data model through HTTP.


Enabling this feature is as easy as registering an SQLAlchemy model in flask-restless. The only thing you need to do, is import the DataModel class from the library and use it to register your api.

import flask
import flask_restless
from flask_sqlalchemy import SQLAlchemy
from flask_restless_datamodel import DataModel
from my_models import Person, Computer, db

app = flask.Flask(__name__)
db = SQLAlchemy(app)

# Create a datamodel instance to register later
data_model = DataModel(manager)

manager = flask_restless.APIManager(app, flask_sqlalchemy_db=db)
manager.create_api(Person, methods=['GET'], include_columns=['name'])
manager.create_api(Computer, methods=['GET'], collection_name='compjutahs', exclude_columns=['name'])
manager.create_api(data_model, methods=['GET'])

Which will expose an endpoint http://localhost:5000/flask-restless-datamodel which in turn will yield a result as followed



This result will be used by the client code to build models on the fly.

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-restless-datamodel-0.2.11.tar.gz (16.6 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page