Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

django-jsonschema converts Django Forms into JSON Schema compatibile representations

Notifications You must be signed in to change notification settings

stanhu/django-jsonschema

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

django-jsonschema converts Django Forms into JSON Schema compatibile representations

Requirements

  • Python 2.6 or later
  • Django 1.4 or later

Usage

To convert a form to a JSON Schema:

from djangojsonschema.jsonschema import DjangoFormToJSONSchema

schema_repr = DjangoFormToJSONSchema().convert_form(MyForm)

To embed a JSON Schema as a form field:

from djangojsonschema.forms import JSONSchemaField

#where schema is a python dictionay like schema_repr in the first exmaple

class MyForm(forms.Form):
    subfield = JSONSchemaField(schema=schema)

form = MyForm(data={'subfield':'<json encoded value>'})
form.validate() #will validate the subfield entry against schema
form['subfield'].as_widget() #will render a textarea widget with a data-schemajson attribute

About

django-jsonschema converts Django Forms into JSON Schema compatibile representations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%