To run a Django-React-Stack app on your local computer, follow these steps:
Step 1: Install Dependencies
1. Install Node.js and npm (Node Package Manager) for the React frontend.
2. Install Python and pip (Python Package Installer) for the Django backend.
Step 2: Set Up the Project
1. Create a new directory for the project and navigate into it.
2. Copy the files from the deployed app into this new directory.
Step 3: Configure the Backend (Django)
1. Navigate into the Django project directory (usually the directory containing `manage.py`).
2. Create a new virtual environment using `python -m venv venv` (or any other name you prefer).
3. Activate the virtual environment using `source venv/bin/activate` (on Linux/Mac) or `venv\Scripts\
activate` (on Windows).
4. Install the required Django packages using `pip install -r requirements.txt`.
5. Run `python manage.py migrate` to apply any pending database migrations.
6. Run `python manage.py runserver` to start the Django development server.
Step 4: Configure the Frontend (React)
1. Navigate into the React project directory (usually the directory containing `package.json`).
2. Install the required React packages using `npm install` or `yarn install`.
3. Start the React development server using `npm start` or `yarn start`.
Step 5: Connect the Frontend and Backend
1. Ensure the Django development server is running (from Step 3).
2. Ensure the React development server is running (from Step 4).
3. Update the React app's API URLs to point to the local Django development server (usually
`http://localhost:8000/`).
You should now be able to access the app on your local computer by visiting `http://localhost:3000/` (or
the port number specified in the React development server output).
Example Use Case
Suppose your Django project is named `backend` and your React project is named `frontend`. Your
directory structure might look like this:
```
bash
my-app/
backend/
manage.py
...
frontend/
package.json
...
```
To run the app locally, follow the steps above, and then access the app at `http://localhost:3000/`.