This project consists of a Django backend for managing the bookstore API and a React frontend for interacting with the API. Follow these steps to set up and run both parts of the application.
Before you begin, make sure you have the following installed:
- Python 3.8+
- Node.js & npm (Node.js version 12+ recommended)
Clone this repository to your local machine:
git clone https://github.com/itsyt/django-bookstore.git
cd django-bookstore
Inside the project directory, create and activate a virtual environment:
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# For Windows
venv\Scripts\activate
# For macOS/Linux
source venv/bin/activate
With the virtual environment activated, install the backend dependencies listed in requirements.txt
:
pip install -r requirements.txt
Navigate to the Django project directory and apply migrations:
python manage.py migrate
Run the following command to start the Django backend server on http://127.0.0.1:8000/
:
python manage.py runserver
Your Django backend should now be running and ready to handle API requests.
Navigate to the frontend
directory and install the React app dependencies using npm
:
cd frontend
npm install
After installing the dependencies, you can start the React development server:
npm start
This will run the frontend on http://127.0.0.1:3000/
, and it should connect to the Django backend API running on http://127.0.0.1:8000/
.
If the API URL or port changes, update it in the apiConfig.js
file in the frontend/src
directory.
- Django Admin Panel: You can access the Django admin panel at
http://127.0.0.1:8000/admin
. - Frontend Development: The React app has hot-reloading enabled, so any saved changes will automatically update in the browser.
- If you encounter issues with package installations or missing dependencies, try deleting the
node_modules
folder in thefrontend
directory and runningnpm install
again. - Ensure your virtual environment is activated when running backend commands.
This project is open-source and available under the MIT License.