How to get Django and ReactJS to work together?

前端 未结 9 1879
无人及你
无人及你 2020-12-04 04:12

New to Django and even newer to ReactJS. I have been looking into AngularJS and ReactJS, but decided on ReactJS. It seemed like it was edging out AngularJS as far as popular

9条回答
  •  失恋的感觉
    2020-12-04 05:02

    I don't have experience with Django but the concepts from front-end to back-end and front-end framework to framework are the same.

    1. React will consume your Django REST API. Front-ends and back-ends aren't connected in any way. React will make HTTP requests to your REST API in order to fetch and set data.
    2. React, with the help of Webpack (module bundler) & Babel (transpiler), will bundle and transpile your Javascript into single or multiple files that will be placed in the entry HTML page. Learn Webpack, Babel, Javascript and React and Redux (a state container). I believe you won't use Django templating but instead allow React to render the front-end.
    3. As this page is rendered, React will consume the API to fetch data so React can render it. Your understanding of HTTP requests, Javascript (ES6), Promises, Middleware and React is essential here.

    Here are a few things I've found on the web that should help (based on a quick Google search):

    • Django and React API Youtube tutorial
    • Setting up Django with React (replaced broken link with archive.org link)
    • Search for other resources using the bolded terms above. Try "Django React Webpack" first.

    Hope this steers you in the right direction! Good luck! Hopefully others who specialize in Django can add to my response.

提交回复
热议问题