DEV Community

Discussion on: How to connect Django to ReactJs

Collapse
 
nagatodev profile image
Faruq Abdulsalam • Edited

Hello Bernard. Here is a screenshot of the folder structure for the tutorial: dev-to-uploads.s3.amazonaws.com/up...

The react frontend application folder replaces the default templates folder from which Django is meant to locate and load templates which would normally be specified in this format 'DIRS': [BASE_DIR/ 'templates'].

However, since we want the Django backend to make use of a react frontend while using a single server: http://127.0.0.1:8000, we need to point Django to the folder where it will get the frontend files which in the tutorial above is the build folder in the frontend directory. Hence the necessity for the STATICFILES_DIRS = [os.path.join(BASE_DIR, 'frontend', 'build', 'static')] line.