Pass extra meta into each field for the OPTIONS call #8495
Unanswered
oesah
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, when we make an OPTIONS call to the API, we get the actions attribute back that contains POST and/or PUT. In actions.POST for instance, we get all the fields, with some meta data. We can use this meta data to build forms in one page applications built with React, Angular or other frameworks.
By allowing to pass additional meta to each, we are able to render a Form in our application just from the OPTIONS calls, which eliminates a lot of work rebuilding all of the logic in the frontend.
I did this with a prototype application I working on right now, and it works like a charm. The only annoying thing is, that I needed to completely overwrite
SimpleMetadata
to achieve this.This is how I did it:
And in my
class APIRootMetadata(SimpleMetadata)
inget_serializer_info()
I added this:Now, in my React application, I just need to get the response from my OPTIONS call and I can build the form completely dynamically. I can even style the material UI form by adjusting the
meta_extra
.Anyway, is this something we could support out of the box? It would be helpful just to be able to add additional meta data to each field with the same logic as we do with
extra_kwargs
.Beta Was this translation helpful? Give feedback.
All reactions