Create and setup a base for a new Django-React app with the following steps:
cd into itpipenv install django djangorestframeworkdjango-admin startproject <project_name><project_name> folderapi and frontend Django app: django-admin startapp <app_name>settings.py file eg.: api.apps.ApiConfigrest_framework to the apps for Reactpython manage.py makemigrationspython manage.py migratepython manage.py runservertemplates folder and within a frontend folderstatic folder and within frontend, css and images folderssrc folder and within a components foldernpm init -ynpm i webpack webpack-cli @babel/core babel-loader @babel/preset-env @babel/preset-react react react-dom --save-devnpm i @material-ui/core @babel/plugin-proposal-class-properties react-router-dom @material-ui/iconsbabel.config.json file and paste the content from herewebpack.config.js file and paste the content from herepackage.json file and delete the test script:
"dev": "webpack --mode development --watch","build": "webpack --mode production"index.js file inside the src folder as paste:import App from './components/App'index.html file inside the templates/frontend folder and paste the content from herecomponents folder inside src and first create an App.js and then paste the content from herefrontend/views.py create an index view:def index(request, *args, **kwargs):
return render(request, "frontend/index.html")frontend create a new urls.py file and add the default path directing to the index view:from django.urls import path
from .views import index
urlpatterns = [
path("", index),
]urls.py add the default path to include the frontend’s urls:path("", include("frontend.urls"))npm run devLinks: