Skip to main content

Convert Django forms into json schema

Project description

Unrest Schema

A library for converting Django forms to json schema endpoints

Usage

First install with pip install unrest_schema and then register any form:

from django import forms
from unrest_schema import register

from myapp.models import MyModel

@register
class MyModelForm(forms.ModelForm):
    class Meta:
        model = MyModel
        fields = ('field1', ...)

Then, in your urls add a the urls for unrest_schema

from django.urls import include

urlpatterns = [
    ..., #other url patterns
    re_path('', include('unrest_schema.urls')),
]

Now visit /api/schema/MyModelForm/ in a browser to get the json representation of MyModelForm. Additionally you can post to /api/schema/MyModelForm/ to create a new MyModel instance or /api/schema/MyModelForm/1/ to modify the MyModel instance with id=1.

Contributing/follow up

Feel free to open a github issue if you want to suggest any features or ask for help. Additionally, the python code for this project is ~150 lines so don't be afraid to dig in!

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

unrest_schema-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file unrest_schema-0.1.1.tar.gz.

File metadata

  • Download URL: unrest_schema-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/2.7.17

File hashes

Hashes for unrest_schema-0.1.1.tar.gz
Algorithm Hash digest
SHA256 21f67292202d62e1d422b2e5a11ecb07333c246fc00f7c372b7f6da3aa6bbbba
MD5 1ba837dfcf20c9e9d7a00020ee074663
BLAKE2b-256 587411d8289a4db5d55c836020387a64bb4d1a95494acb9e91036f80a63af44c

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