Django + React.js

I’m going down this tightrope of how much I should separate Django from my frontend (React.js in my case). I’ve built apps with DRF in the past, where Django is fully disconnected from the frontend. But find it too much overhead to serialize everything. Particularly when I’m in the early stages of development.

As such, I’m toying with creating a template tag which would allow me to instead use Django’s views, and to json encode data sent to templates. I’d then use webpack to bundle my .js with the same element id and props declared. That should let me use component-level React.js within my Django templates without needing to use DRF.

Has anyone done anything like this? I’ve got it in my head how to pull something together. But thought the community may have already had a solution for this.

Scratch that – Just found this: GitHub - zagaran/django-react-components

Which is pretty close to what I had in mind.

1 Like