Django-react project integration
In this tutorial we will learn connect react app into django by few steps
Step 1: Suppose you have project folder directory like as :
Ecom_project
-> back-end
->front-end
Firstly go to front-end directory run command : npm run build
Then move front-end directory into back-end
Step 2: go to settings.py file and edit this like below:
Import os
‘DIRS’ :[os.path.join(BASE_DIR,’ecom_project/build’)]
STATICFIELS_DIRS = [ os.path.join(BASE_DIR, ‘ecom_project/build/static’)]
Step 3:
Go to urls.py file and add this
from django.views.generic import TemplateView
path(‘ ‘, TemplateView.as_view(template_name=’index.html’)),