Skip to content

IDE Setup

Setting up a dev envΒΆ

Please follow the Kartoza coding standards.

πŸƒβ€β™‚οΈ How To Run Project with Visual Studio CodeΒΆ

Copy and customize environnment file: Create a copy of the deployment/.template.env file and name it deployment/.env. Update the deployment/.env file with your project-specific settings. image

Add a .env file in the project root directory with the below content:

COMPOSE_PROJECT_NAME=sanbi

This is to ensure the containers that VS Code builds are using that project name. For more information, follow this link.

Ensure Dev Containers extension is installed image

Build and open project in devcontainer: press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux) to open the Command Palette. Type Dev Containers: Rebuild and Reopen in Container and select it to reopen the folder inside the devcontainer. image

Change the permissions of the django_project folder:

chmod -R a+rw django_project

Install dependencies inside the container: Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux), type Tasks: Run Tasks and select it. Choose React: Install dependencies to install the necessary dependencies.

image

image

Run the migrations inside the container: Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux), and type Tasks: Run Tasks and select it. Choose Django: Migrate.

image

django-migrate

πŸ‘©β€πŸ’» Open the developer siteΒΆ

Run the project inside the container: Press Cmd+Shift+D (macOS) or Ctrl+Shift+D (Windows/Linux), and choose Django+React in the RUN AND DEBUG dropdown.

image

Review the list of forwarded ports from the container to your local host:

forwarded-ports

Open your web browser and go to localhost:8000 to view the running application.

πŸ‘©β€πŸ­ Create a super userΒΆ

django-superuser1

πŸ’½ Restoring layer schema for mapΒΆ

The full dump file for layer schema is ~5.3GB, meanwhile compact dump file is only 24MB.

Download Full Dump File for Layer.

Download Compact Dump File for Layer.

Preview for compact dump file: sanbi_maps_compact

Copy the dump file to db container. Then run pg_restore from inside db container to restore the dump file.

docker cp sanbi_layer_db_compact.dump deployment-db-1:/home/sanbi_layer_db_compact.dump
docker exec -it deployment-db-1 /bin/bash
cd /home
pg_restore -h 127.0.0.1 -U docker -d django -n layer sanbi_layer_db_compact.dump

Load FixturesΒΆ

To load fixtures into your database, you can use the loaddata management command.

Run this command to load all the fixtures.

cd django_project
python manage.py loaddata fixtures/*.json

Run this command to load the specific fixture.

cd django_project
python manage.py loaddata fixtures/<name of the fixture>.json