0

So I am new to React and I can currently create different functional components when I use npx create-react-app appname but if I want to "package" these files and send them to my Django's view page, what is the best way to do this? I am having some trouble with webpack configuring everything in the methods I've attempted. I am trying to create a web app. Thank you.

1 Answer 1

1

Basically to "deploy" Django + React app, you need to use webpack on your react project, then you store react webpacked scripts in your staticfiles directory in django. Then, you define a view that returns index.html with attached scripts {% static 'reactscripts.js' %}. Thats basically all if you want to combine theese two on simple project.

I hope thats the answer you're looking for.

[edit] Also if you would like to deploy your project (after you've figured everything out), this article may help you to do so https://mattsegal.dev/django-spa-infrastructure.html

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer! Exactly what I was looking for! Quick question for you: how did you learn about webpack and fullstack development? I'm a mechanical engineer so I am teaching myself programming, but only through projects and youtube tutorials. Any other resources that you can recommend?
Glad to help! I'm not really a fullstack developer but learning backend developer. I've started learning from basic course on Udemy (youtube is also great!). Some very great channels that I reccomend are: Dennis Ivy, JustDjango and TechWithTim. And also fun fact, the question that you've asked is exactly my problem from 3 weeks ago because I've been doing small django + react project with my friend without any react knowledge. Also, if you have any questions feel free to message me, begginings are hard. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.