- Get a copy of the
local_settings
from one of the developers. - Run database separately, either a docker container or a system service. It's not included as part of the project setup.
- Change
DATABASES
in the local_settings file to connect to your database. - Create a python virtual env -
python3 -m venv venv
- Activate the environment -
source venv/bin/activate
- Install dependencies -
pip install -r requirements.txt
- Run -
pre-commit install
to enable pre-commit git hooks - Run migrations -
python manage.py migrate
- Run server -
python manage.py runserver
There are following main directories:
1. apps. Contains all the apps of this project. All the configuration has been changed to identify the apps under this directory. To create an app, first create the directory inside apps
, then run django-admin startapp <app_name> apps/<app_name>
.
# From the root directory
> mkdir apps/<app_name>
> django-admin startapp <app_name> apps/<app_name>
2. apiserver. Contains all the configuration and settings.
The code snippet in settings.py
and present below ensures that the apps
directory is treated as the parent of all the apps.
# Use apps directory as parent of all the apps
sys.path.insert(0, os.path.join(BASE_DIR, "apps"))
All the configurations for the project are to be stored here. The current structure has the following configurations.
wsgi.py
- Sync server configasgi.py
- Async server configurls.py
- Root URL configsettings/
- This directory contains all django and application related settings
- Amal Salvin Joseph - [email protected]
-
You are not repeating the code, follow DRY (Do not Repeat Yourself)
-
Add logs as much possible. Use the configured logger to do the same with appropriate log level. Examples:
""" My module """ import logging logger = logging.getLogger(__name__) logger.info("My awesome message with %s", variable) logger.error("Some weird error %s", err_msg) logger.debug("I can show detailed debug-agnostic logs")
-
Add comments when you know that re-visiting particular snippet will need help and needs explanation.
-
Make sure that you install
black
as the formatter in your editor. -
Refer this document to configure black in you editor
-
Git guidelines: Use Conventional Commits