Discussion:
Use fields meta to create forms for Javascript client applications!!!!
Oliver Zhou
2018-05-14 18:18:39 UTC
Permalink
Unclear to me exactly what you're asking for - but it seems like you
probably just want a ModelSerializer/ViewSet, and then perhaps doing an
"OPTIONS" API call to the View to get basically what you're looking for.
(But not exactly)

Then - if you need additional customization there - you would then override
the SimpleMetadata class
http://www.django-rest-framework.org/api-guide/metadata/

This also seems like a good place to start
- https://github.com/drf-forms/drf-schema-adapter
Hello Community!
I'm quite new to Django REST Framework and I just can't get tired to say
out loud how AMAZING!!! it is. I know everyone knows this but...
Here's a doubt, that might sound stupid.
I'm building a web application with ReactJS as a client for the DRF.
I know that is possible to use models to render forms and HTML, jus like
the browseable API probably does under the hood and that is completely fine
when using the "tradicional Django way" which is, let's say... a view
sending data to templates, but this is not my case.
So what I'm trying to achieve is to render forms with ReactJS based on
model fields.
box_name = models.CharField(.....)
files_count = models.IntegerField(....)
{'box_name':'CharField', 'files_count':'IntegerField'}
So I will build a view that "inspects" a single "Boxes" object and by it's
"_meta" method, build the above Python dictionary. I kinda know how to
implement everything, but I get the feeling to be repeating myself..... so,
questions are.....
Has anyone ever done such thing?
Is it a good practice?
Is there any other 'easy' way to achieve this?
Thanks everyone and Happy Coding!
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...