DEV Community

Cover image for Django Templates with React

Django Templates with React

Nick K on February 11, 2022

Django Templates with React I'm relatively new to the Django world, and I love it for the amount of ready-to-use solutions. The only thi...
Collapse
 
chat2neil profile image
chat2neil

Great work thanks. This has really helped with my project.

Collapse
 
thanasisxan profile image
Thanasis Xanthopoulos

exactly what I was looking for without extra unecesary libraries or complexity

Collapse
 
tombohub profile image
tombohub

And then you can manipulate context as a react state? How do you send data to views? Also there is project that integrates react and Django but I forgot it's name

Collapse
 
hexnickk profile image
Nick K

In my setup I just used normal Django flow with forms and POST requests for data updates and React mostly for read-only templates, so once page will be reloaded by POST request, there will be a new data in your hook.

To speed things up, you can either enforce caching policy for JS files, or update state locally and send new data to the API.

Collapse
 
mrmonroe profile image
Matthew Monroe

You sir, are a genius.

Collapse
 
momatininja profile image
momo

Is there a way to do this as single page. For example when you goes to another page music doesn't get restarted or paused?

Collapse
 
hexnickk profile image
Nick K

Haven't researched into that, maybe you can start with rendering and then transition to PWA, but this way you won't be able to pass data in templates 🀷