This guide provides step-by-step instructions to set up the backend environment. This will allow you to run the server locally and make API calls from the frontend.
Follow these steps to configure your development environment for the first time.
First, clone the project repository to your local machine.
git clone <your-repository-url>
cd courseschedulerThis project uses Conda for managing Python dependencies.
- If you don't have it, install Miniconda.
- Create the Conda environment from the
conda.yamlfile:
conda env create -f conda.yaml
conda activate /opt/homebrew/Caskroom/miniconda/base/envs/courseschedulerThe backend uses a MySQL database.
- Download and install MySQL Server (version 8.0 or newer) from the official MySQL website.
- During installation, you will be asked to set a root password. Remember it.
- After installation, open the MySQL command line client or your preferred SQL GUI.
Run the following SQL commands to create the database and a dedicated user. Using these exact credentials will ensure your setup matches the team's standard, avoiding configuration issues.
-- Create a new user named 'localdev' with a password
CREATE USER 'localdev'@'localhost' IDENTIFIED BY 'CheckWP';
-- Create the database
CREATE DATABASE coursescheduler CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Grant all permissions on the new database to the new user
GRANT ALL PRIVILEGES ON coursescheduler.* TO 'localdev'@'localhost';
-- Apply the changes
FLUSH PRIVILEGES;Create a .env file inside the backend/ directory. This file stores the database credentials.
DB_HOST=127.0.0.1
DB_USER=localdev
DB_PASSWORD=CheckWP
DB_NAME=courseschedulerFinally, apply the database migrations to set up the tables and create an admin user.
# Navigate to the backend directory
cd backend
# Apply database migrations
python manage.py migrate
# Create a superuser to access the admin panel
python manage.py createsuperuserFollow the prompts to create your admin username and password.
Follow these steps each time you start working on the project.
Always make sure your Conda environment is active.
conda activate /opt/homebrew/Caskroom/miniconda/base/envs/courseschedulerRun the Django development server from the backend directory.
cd backend
python manage.py runserverThe backend API will now be running at http://127.0.0.1:8000/. You can now make API calls from the frontend to this address.
If you have sample data, test data, or want to share your current database state with frontend developers:
# Export all data to a JSON fixture file
python manage.py dumpdata > sample.json
# Or export specific apps only (recommended for large databases)
python manage.py dumpdata courses users scheduling > sample.json
# Share this file with your team membersTo load the shared data into your local database:
# 1. Make sure you've completed the one-time setup above
# 2. Apply all migrations first
python manage.py migrate
# 3. Load the shared data
python manage.py loaddata sample.jsonImportant Notes:
- Always run migrations before loading data
- The
sample.jsonfile should be placed in your project root or in any app'sfixtures/directory - This ensures both backend and frontend developers have the same test data to work with
- If you get conflicts, you may need to reset your database and start fresh
Example workflow:
# Backend developer shares data
python manage.py dumpdata > team_sample_data.json
# (shares file via Git, Slack, etc.)
# Frontend developer loads data
python manage.py migrate
python manage.py loaddata team_sample_data.json
python manage.py runserver
# Now frontend has same data as backend for testing