As mentioned previously, there are a few different ways to work with Django and React. We're going to set up our frontend separately and let React do its thing, let Django do its thing, and have them shake hands in the middle. This approach does have its limitations, as we'll see, but it's a basic introduction. We'll get more complicated later on.
Let's set it up, starting with creating a new React application:
-
Change to the shakespearebot directory (not bot) and execute npx create-react-app react-frontend.
-
Go ahead and execute cd react-frontend && yarn start and access the development server at http://localhost:3000, just to be sure everything is good. You should receive the React demo page at the preceding URL. Stop the server with Ctrl + C.
-
Execute yarn build.
Now, here's where things get a little limited. What we've done right now is execute what creates a production-optimized build of the site. This is...