Skip to main content

A platform independent form serializer for Django.

Project description

django_remote_jsonschema_forms

A package that allows you to serialize django forms, including fields and widgets into Python dictionary for easy conversion into JSON Schema.

This way one can expose a django form using the JSON Schema standard.

These forms can be then rendered using JS libraries like react-jsonschema-form.

This package is heavily based on django-remote-forms, which we have used as an example.

We have changed the output format that django-remote-forms provides and return a JSON Schema compatible format.

Usage

Say you have a django form like this one:

from django.db import models
from django import forms

class Task(models.Model):
    text = models.TextField("Text")
    email = models.TextField("Text")

class MyForm(forms.ModelForm):

    class Meta:
        model =  Task

You can create a view to expose it in JSON Schema like this:

from .forms import MyForm
from django_remote_jsonschema_forms.forms import RemoteJSONSChemaForm
from django.http import JsonResponse

def json_schema_form_view(request):
    form = MyForm()
    remote_form = RemoteJSONSChemaForm(form)
    return JsonResponse(remote_form.as_dict())

Remember that you will need to register a url in urls.py to expose it.

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

django_remote_jsonschema_forms-1.0.0.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file django_remote_jsonschema_forms-1.0.0.tar.gz.

File metadata

File hashes

Hashes for django_remote_jsonschema_forms-1.0.0.tar.gz
Algorithm Hash digest
SHA256 613232e1eefc146487ecdf7a41aca1dc8c3a04328cc114083b582734da490f8e
MD5 2bbee94ce1d5e6512d15e5e11044c5ea
BLAKE2b-256 de2bee64c98581a6225aa603c0addc08dac89e9eebcc5e6d3a19034139abf3b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page