Another Django + DRF + Poetry template for cookiecutter
-
If necessary, create and activate a virtual environment in one of the following ways:
Or in another way compatible with poetry
-
Install cookiecutter using this instruction
-
Run postgres server and create database for project
-
Create project from template:
cookiecutter gh:md5orsha256/django-drf-template
For interactive project creation
OR
cookiecutter gh:md5orsha256/django-drf-template \ --no-input \ project_name=<project_name> \ project_slug=<project_slug> \ project_description=<project_description> \ project_version=<project_version> \ django_settings_package=<django_settings_package> \ author=<author> \ use_sentry=<use_sentry> \ ENV_DEBUG=<ENV_DEBUG> \ ENV_SECRET_KEY=<ENV_SECRET_KEY> \ ENV_DB_NAME=<ENV_DB_NAME> \ ENV_DB_USER=<ENV_DB_USER> \ ENV_DB_PASSWORD=<ENV_DB_PASSWORD> \ ENV_DB_HOST=<ENV_DB_HOST> \ ENV_DJANGO_STATIC_ROOT=<ENV_DJANGO_STATIC_ROOT> \ ENV_SENTRY_DSN=<ENV_SENTRY_DSN> \ ENV_DJANGO_ALLOWED_HOSTS=<ENV_DJANGO_ALLOWED_HOSTS>
To run without asking for user input
In one case or another - you need to set values for some parameters, the descriptions of which you can read here
Parameter name | Required | Description |
---|---|---|
project_name | ➕ | The name of the project. Will be used in the README.md file. It also creates a default value for the project_slug variable from this value. |
project_slug | ➖ | Used for the name of the root directory of the Django project, [tool.poetry].name value in pyproject.toml, also as the default database name in the ENV_DATABASE_URL variable |
project_description | ➖ | Used in README.md, [tool.poetry].description value in pyproject.toml |
project_version | ➖ | Used as [tool.poetry].version value in pyproject.toml |
django_settings_package | ➖ | The name of the configuration django application (the application that stores the settings.py file) |
author_name | ➕ | Used as part of [tool.poetry].authors value in pyproject.toml |
author_email | ➕ | Used as part of [tool.poetry].authors value in pyproject.toml, drf-yasg contact email |
use_sentry | ➖ | Determines whether sentry will be used in the project. If yes, sentry-sdk will be installed and configured |
ENV_DEBUG | ➖ | Used to generate .env file. A boolean that turns on/off debug mode in django |
ENV_SECRET_KEY | ➖ | Used to generate .env file. Secret key for django-project |
ENV_DB_NAME | ➖ | Used to generate .env file. |
ENV_DB_USER | ➕ | Used to generate .env file. |
ENV_DB_PASSWORD | ➕ | Used to generate .env file. |
ENV_DB_HOST | ➖ | Used to generate .env file. |
ENV_DJANGO_STATIC_ROOT | ➖ | Used to generate .env file. Directory for storing static files |
ENV_SENTRY_DSN | if use_sentry = "yes" | Used to generate .env file. Sentry DSN only if use_sentry = "yes" |
ENV_DJANGO_ALLOWED_HOSTS | ➖ | Used to generate .env file. Django ALLOWED_HOSTS |
You can see the default value in the configuration file
This template is intended for creating API applications, therefore it does not include libraries that extend the functionality of templates
- Django
- DRF
- drf-yasg - for API documentation
- django-auditlog
- django-environ-2
- django-split-settings
- flake8 with plugins:
- flake8-absolute-import
- flake8-bugbear
- flake8-cognitive-complexity
- flake8-django
- flake8-eradicate
- flake8-isort
- flake8-fixme
- flake8-mock
- flake8-multiline-containers
- flake8-mutable
- flake8-pep3101
- flake8-pie
- flake8-print
- flake8-printf-formatting
- flake8-pytest
- flake8-pytest-style
- flake8-quotes
- flake8-simplify
- flake8-todo
- flake8-use-fstring
- flake8-variables-names
- flake8-walrus
- mypy
- bandit
- black
- isort
- coverage
- factory-boy
- pytest-django
More information can be found in the pyproject.toml file
- Fix static path template parameter
- add poetry.lock file
- Create docker-ignore file
- Test coverage configuration
- Add docker-compose file for tests running
- Add docker-compose file for production
- Create factory for User
- Configure a12n
- Install and configure loguru
- Install and configure django-log-request-id
- Add healthcheck
- Add metrics
- Add profiler
- Make DB driver changeable
- Update Makefile with docker-compose or docker
- Create gh action in project (test running, linter and dependabot)
- Add running tests and linter checking on post_gen_project