Skip to content

About

A Django REST API for an eLearning platform.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Getting Started Guide

Welcome to the eLearning API project! This guide will help you set up and run the project on your local machine.

Prerequisites

Before you begin, ensure you have the following installed:

Setting Up

1. Clone the repository

Once cloned, cd into the repository. All commands to run in the next steps will be inside this directory.

git clone https://github.com/jnous-5/elearning-api.git
cd elearning-api

2. Open in VS Code

Inside VSCode, click Reopen in Container when prompted. If there's no prompt, manually open by hitting ⌘ + ⇧ + P (Command + Shift + P) and select Dev Containers: Reopen in Container command.

code .

3. Create config file

Duplicate the env file template and replace its configuration values to match your setup.

cp .env.example .env

4. Install dependencies

A postCreateCommand is configured from the dev container to automatically install dependencies once the container is created. If the script fails, you can manually install the dependencies by running the command below.

poetry install

5. Run django migrations

python manage.py migrate

6. Create superuser account (Optional)

If you want to login to django's admin interface, run the following command and follow along the prompt.

python manage.py createsuperuser

7. Run the application

Start django's dev server.

python manage.py runserver

Base API endpoint: http://127.0.0.1:8000/api

Django admin interface: http://127.0.0.1:8000/admin

Testing

There are 2 types of testing currently present in the app: unit and integration tests. Unit tests reside in the tests/unit directory while integration tests reside in tests/integration.

Run the test

To run the tests (both unit and integration), run the following command.

python manage.py test # or python manage.py test --shuffle

Code coverage

To generate code coverage, first run the tests using the following command.

coverage run manage.py test

Then generate the html report. The report can be found in htmlcov/index.html.

coverage html

Troubleshooting

1. I can't run python commands in the terminal.

The app uses poetry for managing dependencies. Make sure when running python you are inside the virtual env created by poetry. If you're using VSCode, normally this should be done automatically for you via the python.defaultInterpreterPath setting found in .vscode/settings.json file.

There are cases wherein opening the terminal in VSCode for the first time doesn't pick up this setting. If that's the case, simply open a new terminal session.

If it still doesn't work, you can always manually activate the poetry shell by running the command:

poetry shell

Verify by checking the installed python path. It should point to /workspaces/elearning-api/.venv/bin/python. This is where python is installed in the container.

which python

User Credentials

Superuser account

Credentials Email: admin@example.com
Password: admin12345

About

A Django REST API for an eLearning platform.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages