Created
March 21, 2019 15:03
-
-
Save slint/81b2be2a9fa78b20e6c186f130192348 to your computer and use it in GitHub Desktop.
nested record example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "http://json-schema.org/draft-04/schema#", | |
| "id": "http://zenodo.org/schemas/records/record-v1.0.0.json", | |
| "properties": { | |
| "formats": { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "properties": { | |
| "width": { | |
| "type": "number" | |
| }, | |
| "height": { | |
| "type": "number" | |
| }, | |
| "thickness": { | |
| "type": "number" | |
| } | |
| }, | |
| "required": [ | |
| "width", "height" | |
| ] | |
| }, | |
| "minLength": 1 | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from invenio_records.api import Record | |
| data = { | |
| "$schema": "http://my-site.org/schemas/records/record-v1.0.0.json", | |
| "formats": [ | |
| {'width': 10, 'height': 5}, | |
| {'width': 12, 'height': 5}, | |
| {'width': 13, 'height': 5}, | |
| {'width': 20, 'height': 5}, | |
| ] | |
| } | |
| rec = Record.create(data) | |
| # if not valid you get ValidationException |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this solved it:
NB: form.hidden_tag() creates automatically a csrf_token! (how am I supposed to know.. :D).
and since the ID of the hidden field is also important, I had to create it inside the loop.
this way:
my output now: