Skip to content
This repository

Python Data Structures for Humans™.

branch: master

This branch is 0 commits ahead and 0 commits behind master


Using the old read the docs theme because the new one kinda broke our stuff... :(
latest commit e7a50727dc
James Dennis authored
Octocat-spinner-32 docs Update December 27, 2013
Octocat-spinner-32 schematics v0.9.4 December 08, 2013
Octocat-spinner-32 tests Merge branch 'default_role' October 31, 2013
Octocat-spinner-32 .coverage Completed merge of Krace's commit, which adds coverage and coverall s… October 26, 2013
Octocat-spinner-32 .gitignore tox integration added August 18, 2013
Octocat-spinner-32 .travis.yml Update .travis.yml October 27, 2013
Octocat-spinner-32 HISTORY.rst Updated history file to reflect recent work. December 08, 2013
Octocat-spinner-32 LICENSE Be more explicit about which license we use so devs can glance at it … September 22, 2013
Octocat-spinner-32 tox integration added August 18, 2013
Octocat-spinner-32 README.rst Cleaning up the testing instructions October 26, 2013
Octocat-spinner-32 dev-requirements.txt Added coverall support October 12, 2013
Octocat-spinner-32 requirements-testing.txt tox integration added August 18, 2013
Octocat-spinner-32 Fixed merged conflicts from olegpidsadnyi October 12, 2013
Octocat-spinner-32 tox.ini tox integration added August 18, 2013


Python Data Structures for Humans™.

Build Status Coverage

For more information, please see our documentation:


Schematics is a Python library to combine types into structures, validate them, and transform the shapes of your data based on simple descriptions.

The internals are similar to ORM type systems, but there is no database layer in Schematics. Instead, we believe that building a database layer is made significantly easier when Schematics handles everything but writing the query.

Further, it can be used for a range of tasks where having a database involved may not make sense.

Some common use cases:


This is a simple Model.

>>> from schematics.models import Model
>>> from schematics.types import StringType, URLType
>>> class Person(Model):
...     name = StringType(required=True)
...     website = URLType()
>>> person = Person({'name': u'Joe Strummer',
...                  'website': ''})
u'Joe Strummer'

Serializing the data to JSON.

>>> import json
>>> json.dumps(person.to_primitive())
{"name": "Joe Strummer", "website": ""}

Let's try validating without a name value, since it's required.

>>> person = Person()
>>> = ''
>>> person.validate()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "schematics/", line 231, in validate
    raise ModelValidationError(e.messages)
schematics.exceptions.ModelValidationError: {'name': [u'This field is required.']}

Add the field and validation passes

>>> person = Person()
>>> = 'Amon Tobin'
>>> = ''
>>> person.validate()

What's with the fork?

At the top of this projects Github page is says "forked from exfm/dictshield". James (@j2labs) started dictshield while working for exfm. It was open sourced, so he forked it and continued work on it.

Alas, the name, which was originally a 3am decision to make me James laugh turned into something that was awkward and a little crude, so it was renamed Schematics.

DictShield still exists, but consider anything with that label to be a ghost from this project's early years.

Testing & Coverage support

Run coverage and check the missing statements.

$ `coverage run --source schematics -m py.test && coverage report`
Something went wrong with that request. Please try again.