In my project, I’m using Ember.js and Django + django-rest-framework.
Some of my models have numeric fields, but with a limited number of options. With django-rest-framework I get this when querying a user with a GET
request (simplified output):
{
"id": 2,
"username": "tapia",
"gender": 1,
"eyes": 1,
}
If I make an OPTIONS
request to the same URL, I get this:
{
"name": "User Detail",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"PUT": {
"username": {
"type": "string",
"required": true,
"read_only": false,
"label": "nombre de usuario",
"help_text": "Requerido. 30 caracteres o menos. Letras, n\u00fameros y @/./+/-/_",
"max_length": 30
},
"gender": {
"type": "multiple choice",
"required": true,
"read_only": false,
"choices": [
{
"display_name": "Male",
"value": 1
},
{
"display_name": "Female",
"value": 2
}
]
},
"eyes": {
"type": "multiple choice",
"required": true,
"read_only": false,
"choices": [
{
"display_name": "Brown",
"value": 1
},
{
"display_name": "Green",
"value": 2
},
{
"display_name": "Black",
"value": 3
},
{
"display_name": "Blue",
"value": 4
},
{
"display_name": "Gray",
"value": 5
},
{
"display_name": "Amber",
"value": 6
},
{
"display_name": "Other",
"value": 7
}
]
}
}
}
}
In Ember, I’m writing a form to edit a user. It would be amazing if I could use the OPTIONS
request to fill the