The problem with ModelForm is translating validation to something front-end, like jquery Validator. Here, DRF does better, because swagger spec includes something like jsonschema (neither are a standard as I used to know them, in the WSDL/SOAP days), and so you can use jsonschema validation to validate on the front-end. I think what is needed is some way to map validate-only to the back-end, and do a sort of 2-phase commit - validate before the user presses OK, and then save (PATCH) when the user presses save/apply/OK.
On Wed, Feb 6, 2019 at 10:03 AM Dmitriy Sintsov <questpc...@gmail.com> wrote: > Speaking of Rails AJAX forms. It's quite trivial to submit Django > ModelForm in Javascript AJAX request. It's a bit harder to have the > customizable success action and to display the field validation errors via > AJAX response. > > I implemented AJAX viewmodels for that: > > > https://django-jinja-knockout.readthedocs.io/en/latest/viewmodels.html#ajax-actions > > However it's the mixed traditional forms + AJAX approach, not the pure > SPA. In pure SPA Django becomes the "data supplier" where most of the > templates, forms, presentation is performed by Javascript framework. > > So, the question is, whether the features of Django such as inline > formsets and custom widgets are required, or should Django become the data > store only. > > On Tuesday, February 5, 2019 at 3:52:42 AM UTC+3, Maciek Olko wrote: >> >> I didn't find this topic being discussed before. >> >> It seems to me to be good idea to place "How do I get Django and my JS >> framework to work together?" or similar question and answer to it in FAQ in >> Django's docs. >> >> Having very big popularity of JS frameworks now it is indeed very common >> question being asked or searched on the Internet. Such question for ReactJS >> has 65k views on StackOverflow [1]. >> >> The answer could briefly explain that one can make use of Django backend >> and produce API to be consumed by JS clients. Probably it would be good to >> link to Django REST API project as a suggestion for big projects. >> >> What do you think about such addition to FAQ? >> >> Regards, >> Maciej >> >> [1] >> https://stackoverflow.com/questions/41867055/how-to-get-django-and-reactjs-to-work-together >> > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at https://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/0cafc96d-bc4f-4316-9022-28e5134a1bcd%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/0cafc96d-bc4f-4316-9022-28e5134a1bcd%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFzonYZvqTVigfjohY6GUqJicuJeOH4pzwd32KAsR4XmnHt9hA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.