2 ms·
Just to expand on this, below is some of the core logic for converting Django forms to React elements. I'm not going to apologise for my crap code - I'm not cr
by andrewstuart 7y ago
Just to expand on this, below is some of the core logic for converting Django forms to React elements.
I'm not going to apologise for my crap code - I'm not creating art I'm making my own applications.
The thing to understand is that I actually do an XMLHTTPrequest to get the Django form and then in JavaScript a create a new separate DOM and put the form and its data in that. In React onchange events in the field I update that DOM that contains the form and its data. When I want to submit back to Django I submit the form from that DOM.
There's more to it than the code here but it should give you an idea:
djangoForm.jsx:
https://gist.github.com/bootrino/65ed6a749799c37862e26562e1e06cf3 https://gist.github.com/bootrino/65ed6a749799c37862e26562e1e...
DjangoRenderFormContext.js
https://gist.github.com/bootrino/7e062770ed331753f18ce37ebd07fd8c https://gist.github.com/bootrino/7e062770ed331753f18ce37ebd0...