mohawk-data-platform
mohawk-data-platform is a Django app for editing and publishing arbitrary JSON data in a form-based environment.
Features
- Define structured models, with custom fields and validation.
- Create, edit and update instances defined models using the Django admin interface.
- Group models into applications for bulk access.
- Access models, instances and applications via a simple JSON API.
- Cross-origin API requests via CORS and JSONP.
Installation
- Checkout the latest mohawk-data-platform release and copy or symlink the
data
directory into yourPYTHONPATH
. If using pip, runpip install mohawk-data-platform
. - Add
'data'
to yourINSTALLED_APPS
setting. - Add
url(r"^", include("data.urls", namespace="data")),
to youurls.py
file. - Install and active the Django admin site, if not already present.
Admin usage
The bulk of the functionality for mohawk-data-platform is found within the admin UI. The basic workflow is:
- Create a
Model
, defining at least oneField
. - Create an
Instance
of that model. - Optionally, create an
Application
. - Edit the model, and add it to the application you created.
Any data you add to the system will be pubically-available via the API endpoints.
Model field reference
Fields added to a model take a number of optional config parameters, suppled as JSON documents. The available fields, and their configuration options, are listed below.
Fields which take choices expect them to be supplied as a list of [value, label]
options:
{ "choices": [ ["#ff0000", "Red"], ["#0000ff", "Green"], ["#00ff00", "Blue"] ] }
Text
A single-line of unicode text.
{ "required": true, "choices": null }
Integer
An integer number.
{ "required": true, "choices": null }
Float
A floating-point number.
{ "required": true }
Date
A date value.
{ "required": true }
Time
A time value.
{ "required": true }
Datetime
A combined date and time value.
{ "required": true }
Boolean
A true/false checkbox.
{}
File
An uploaded file.
{ "required": true }
Long text
Multiple lines of unicode text.
{ "required": true }
Model
A reference to an instance of a model.
{ "required": true, "model_id": "<model_id>" // The type of instance being referenced. }
Multi model
A reference to multiple instances of a model.
{ "required": true, "model_id": "<model_id>" // The type of instance being referenced. }
API endpoints
GET /<model_id>.json
Returns all online instances of the given model:
{ "status": "OK", "message": "Instances of Your Model were successfully loaded.", "instances": [ { "_date_created": "<timestamp>", "_date_modified": "<timestamp>", "_id": "<instance_id>", "_model": "<model_id>", "<field_name>": "<field_value>", ... }, ... ] }
GET /<model_id>/<instance_id>.json
Returns the given instance:
{ "status": "OK", "message": "Instances of <model_name> were successfully loaded.", "instance": { "_date_created": "<timestamp>", "_date_modified": "<timestamp>", "_id": "<instance_id>", "_model": "<model_id>", "<field_name>": "<field_value>", ... } }
GET /a/<application_id>.json
Returns all online instances within the given application:
{ "status": "OK", "message": "Instances within application <application_name> were successfully loaded.", "instances": [ { "_date_created": "<timestamp>", "_date_modified": "<timestamp>", "_id": "<instance_id>", "_model": "<model_id>", "<field_name>": "<field_value>", ... }, ... ] }
More information
The mohawk-data-platform project was developed at Mohawk, and is released as Open Source under the MIT license.
You can get the code from the mohawk-data-platform project site.
Contributors
The following people were involved in the development of this project.
- Dave Hall - Blog | GitHub | Twitter | Google Profile