/django-drf-template

Yet another Django DRF cookiecutter template

Primary LanguagePythonMIT LicenseMIT

Django DRF cookiecutter template

License: MIT GitHub last commit last build

Another Django + DRF + Poetry template for cookiecutter

Dependencies:

Installation

  1. If necessary, create and activate a virtual environment in one of the following ways:

    Or in another way compatible with poetry

  2. Install cookiecutter using this instruction

  3. Run postgres server and create database for project

  4. 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

clean display

Template parameters

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

What's included in the template?

This template is intended for creating API applications, therefore it does not include libraries that extend the functionality of templates

Development tools:

More information can be found in the pyproject.toml file

TODO

  • 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