This repository is intended as a cookiecutter for Django projects.
You can choose to remove some technologies, whichever fits your project needs.
- Django 3.10.2 and Django REST
- Backend framework used to create APIs, and is the main technology used in this repository.
- Sendgrid
- Used for sending transactional emails.
- Twilio
- Used for SMS--sending verification codes, in particular.
- Swagger UI
- Visual documentation of available APIs.
- Docker
- For containerizing apps.
- Pre-commit
- Framework for managing and maintaining multi-language pre-commit hooks.
- Autoflake8
- Tool to automatically fix some issues reported by flake8. A fork from autoflake and is used to remove unused imports and unused variables.
- Isort
- Utility / Library to sort Python imports.
- Black
- Uncompromising Python code formatter.
- TeleSign
- For sending SMS, 2FA SMS.
- Create a virtual environment named
venv
python3 -m venv venv
-
Set environment variable values.
-
Get inside the environment, upgrade pip and install the packages listed in requirements.
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements/development.txt
- Create environment file based on environment mode, and change the values.
For development mode, duplicate
environment/dev.template.env
and rename the duplicate file toenvironment/development.env
. For staging mode, duplicateenvironment/staging.template.env
and rename the duplicate file toenvironment/staging.env
. For staging mode, duplicateenvironment/production.template.env
and rename the duplicate file toenvironment/production.env
.
- Up the server
If just using the terminal, run
python manage.py runserver
If using Pycharm IDE, refer docs/pycharm.md
to read about creating Django server configurations.
- Run migrations
python manage.py migrate
- Create superuser
python manage.py createsuperuser
- Happy hacking!
Print sample config yaml file.
pre-commit sample-config > .pre-commit-config.yml
Install pre-commit
pre-commit install
Uninstall pre-commit
pre-commit uninstall
python manage.py test --pattern="tests_*.py"
python manage.py test apps/services/"
python -m unittest test_file
python -m unittest test_sendgrid
Code coverage testing for Python. It measures code coverage, typically during test execution. It uses the code analysis tools and tracing hooks provided in the Python standard library to determine which lines are executable, and which have been executed.
coverage run --omit='*/venv/*' manage.py test
coverage report # get report
coverage html # will generate an HTML report with a folder htmlcov/