REST API for the MacFAST project built with the Django REST framework, deployed on the university's network at https://macfast.ca.
-
Clone the Repository:
git clone https://github.com/McMaster-FAST/backend.git cd backend -
Create and Activate Virtual Environment: Using
uv:uv venv source .venv/bin/activate(Or with standard
venv:python -m venv .venvandsource .venv/bin/activate) -
Install Dependencies:
uv sync
The project uses a .env file for managing secrets and environment-specific settings. System environment variables take precedence over values loaded from .env.
-
Create your Environment File: Copy the sample file to create your local environment file. This
.envfile is in.gitignoreand should never be committed to source control.cp sample.env .env
-
Edit your
.envFile: Open the.envfile in your editor and fill in the required values. The comments insample.envwill guide you.
-
Apply Database Migrations:
uv run manage.py migrate
-
Run the Development Server:
uv run manage.py runserver
The server will start on
http://localhost:8000/.
If you hit an error like:
InconsistentMigrationHistory: analytics.0007 ... applied before analytics.0006 ...,
run:
uv run manage.py repair_analytics_migration_history
uv run manage.py migrateTo preview without changing anything:
uv run manage.py repair_analytics_migration_history --dry-runIf you are doing development and need mock data to test with you can run
To load mock data only if the database is empty:
uv run manage.py load_fixtures
or to load all mock data unconditionally:
uv run manage.py loaddata mock/data.json
To unload mock data:
uv run manage.py unload_fixtures
You can test that the server is running correctly by hitting the API's health check "ping" endpoint.
Endpoint: GET /api/core/ping/
Example using a Browser: With the server running, visit the following URL in your browser: http://localhost:8000/api/core/ping/
Expected Response
{
"message": "pong"
}
You can run the unit tests for the project by running the following command:
uv run pytest
or run tests for a specific test file (e.g. the OIDC backend tests):
uv run pytest core/tests/test_oidc_backend.py