d4x1 / django-with-react

set up a django project with modern js framework(such as react) without disabling django's template system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excellent, Thanks!

NickWinston123 opened this issue · comments

Thank you for this, this is working perfectly.

Took a few different repos to find one that worked

Going forward would I mainly be copying and creating different index.js files for my reactjs pages / components?

And instead of using two separate servers, I am using the /demo folder (or link) (that comes from django) to act as the backend. Is that right?

When I edit the index.js in assets the react page does not reload, I have to edit the index-bundle.js within static for it to update. Is there a way to make it automatically regenerate index-bundle when I make a change?

Q1

Going forward would I mainly be copying and creating different index.js files for my reactjs pages / components?

Yes. Just do front-end programmer's work as usual.

Q2

And instead of using two separate servers, I am using the /demo folder (or link) (that comes from django) to act as the backend. Is that right?

Yes. That's the reason I create this demo project. In fact the /demo/react URL routes your request to react's index page).

Q3

When I edit the index.js in assets the react page does not reload, I have to edit the index-bundle.js within static for it to update. Is there a way to make it automatically regenerate index-bundle when I make a change?

In modern web dev, almost all web pages need to be compiled, so every change needs a re-compiled index-bundle.js .
You need to run npm run dev and never kill it, so your changes in assert folder (such as index.js) can be built to index-bundle.js when you enter Ctrl+S. And run python manage.py runserver to watch files' changes in Django project.
All you need to do is refresh your browser.

Awesome, thanks again!