Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS Framework able to generate forms based on (django) rest api OPTIONS

I am using the Django REST Framework.
When using the browsable API, after clicking on the OPTIONS button, I see beautiful definitions of fields and allowed actions for the resource, for example this user resource below:

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS

{
    "name": "XSpot User Detail", 
    "description": "", 
    "renders": [
        "application/json", 
        "text/html"
    ], 
    "parses": [
        "application/json", 
        "application/x-www-form-urlencoded", 
        "multipart/form-data"
    ], 
    "actions": {
        "PUT": {
            "url": {
                "type": "field", 
                "required": false, 
                "read_only": true
            }, 
            "mail_sent": {
                "type": "boolean", 
                "required": false, 
                "read_only": false, 
                "label": "mail sent"
            }, 
            "email": {
                "type": "email", 
                "required": true, 
                "read_only": false, 
                "label": "email address", 
                "max_length": 255
            }
        }
    }
}

QUESTION: are there any JS frameworks able to utilize this meta information to generate forms?

like image 254
andilabs Avatar asked Jul 22 '14 17:07

andilabs


People also ask

Can Django be used for REST API?

Django REST framework is a powerful and flexible toolkit for building Web APIs. Some reasons you might want to use REST framework: The Web browsable API is a huge usability win for your developers.

What is Django REST framework browsable API?

The browsable API feature in the Django REST framework generates HTML output for different resources. It facilitates interaction with RESTful web service through any web browser. To enable this feature, we should specify text/html for the Content-Type key in the request header.

What is difference between Django and Django REST framework?

Django is the web development framework in python whereas the Django Rest Framework is the library used in Django to build Rest APIs. Django Rest Framework is especially designed to make the CRUD operations easier to design in Django. Django Rest Framework makes it easy to use your Django Server as an REST API.


1 Answers

Well i think this could be helpful http://formly-js.github.io/angular-formly this takes JSON and renders a HTML form.

like image 167
Julian Cantillo Avatar answered Sep 21 '22 09:09

Julian Cantillo