diff --git a/{{ cookiecutter.project_slug }}/README.md b/{{ cookiecutter.project_slug }}/README.md index 1a5495d..ab46305 100644 --- a/{{ cookiecutter.project_slug }}/README.md +++ b/{{ cookiecutter.project_slug }}/README.md @@ -2,36 +2,40 @@ [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://docs.astral.sh/ruff/formatter/) -### List of services: ### +## List of services * Dev server: [https://{{ cookiecutter.domain_name }}/](https://{{ cookiecutter.domain_name }}/) -### Documentation: ### +## Documentation * [Architecture overview](docs/architecture_overview.md) * [Backend: Routine tasks](docs/commands.md) * [Backend: Pre-commit hook](docs/pre_commit_hook.md) * [Backend: Docker configuration](docs/docker.md) -### API documentation: ### +## API documentation * ReDoc web UI: [https://{{ cookiecutter.domain_name }}/_platform/docs/v1/redoc/](https://{{ cookiecutter.domain_name }}/_platform/docs/v1/redoc/) * Swagger web UI: [https://{{ cookiecutter.domain_name }}/_platform/docs/v1/swagger/](https://{{ cookiecutter.domain_name }}/_platform/docs/v1/swagger/) * Schema YAML: [https://{{ cookiecutter.domain_name }}/_platform/docs/v1/schema/](https://{{ cookiecutter.domain_name }}/_platform/docs/v1/schema/) -### First run: ### +## First run Application is running in docker containers. ### Prerequisites Installed [docker](https://docs.docker.com/engine/install/) -Copy initial settings for Django project: +### Copy initial settings for Django project ```bash cp ./api/.env.example ./api/.env ``` +> [!IMPORTANT] +> It is highly advised to use custom admin location instead of default `admin/`. +> To do that you need set `{{ cookiecutter.__env_prefix }}DJANGO_ADMIN_URL` environment variable in `./api/.env` file +> with custom value. -Run application with required services: +### Run application with required services ```bash make compose-up @@ -39,17 +43,28 @@ make compose-up Your application will be available at [http://localhost:8000](http://localhost:8000) -How it works: - - `make compose-up` will run docker-compose with (all services)[docker/docker.md] - - if images is missed it will build them - - if there is no `poetry.lock` file present, Poetry simply resolves all dependencies listed in your - `api/pyproject.toml` file and downloads the latest version of their files. - But in any case it's good practice to lock your dependencies and share the lock file with your team, - to do that run `make poetry-lock` command, and commit `poetry.lock` file to the repository. - - it will use `api/.env` file to set environment variables for `api` and `celery` services. Check `env_file` section in [docker-compose.yml](docker/docker-compose.yml) +#### How it works +- `make compose-up` will run docker-compose with [all services](docker/docker.md) + - if images is missed it will build them + - if there is no `poetry.lock` file present, Poetry simply resolves all dependencies listed in your + `api/pyproject.toml` file and downloads the latest version of their files. + But in any case it's good practice to lock your dependencies and share the lock file with your team, + to do that run `make api-lock` command, and commit `poetry.lock` file to the repository. +- it will use `api/.env` file to set environment variables for `api` and `celery` services. Check `env_file` section in [docker-compose.yml](docker/docker-compose.yml) Any changes in docker files or python dependency will require to rebuild images, to do that run `make compose-build` command. +### Create superuser +Run bash on `api` docker container +```bash +make api-bash +``` +Run `createsuperuser` manage.py command +```bash +python manage.py createsuperuser +``` +Follow instructions + ### Docker Application is running in docker containers. It allows to run application in the same environment on any machine with minimal setup. diff --git a/{{ cookiecutter.project_slug }}/api/.env.example b/{{ cookiecutter.project_slug }}/api/.env.example index b9cf390..a01877a 100644 --- a/{{ cookiecutter.project_slug }}/api/.env.example +++ b/{{ cookiecutter.project_slug }}/api/.env.example @@ -1,4 +1,4 @@ -{{ cookiecutter.__env_prefix }}ALLOWED_HOSTS=127.0.0.1, +{{ cookiecutter.__env_prefix }}ALLOWED_HOSTS=127.0.0.1,0.0.0.0,localhost {{ cookiecutter.__env_prefix }}SECRET_KEY=secret-key {{ cookiecutter.__env_prefix }}DEBUG=on @@ -12,6 +12,7 @@ {{ cookiecutter.__env_prefix }}EMAIL_PORT=1025 {{ cookiecutter.__env_prefix }}EMAIL_USE_TLS=off +{{ cookiecutter.__env_prefix }}DJANGO_ADMIN_URL=admin/ # Minio credentials AWS_S3_ACCESS_KEY_ID={{ cookiecutter.__minio_access_key }} diff --git a/{{ cookiecutter.project_slug }}/api/Makefile b/{{ cookiecutter.project_slug }}/api/Makefile index 16511fe..ae7c2eb 100644 --- a/{{ cookiecutter.project_slug }}/api/Makefile +++ b/{{ cookiecutter.project_slug }}/api/Makefile @@ -28,7 +28,7 @@ check-fix: ruff format . ruff check --fix-only --show-fixes --statistics . -run:migrate collectstatic +run: migrate collectstatic python manage.py runserver_plus 0.0.0.0:8000 --nostatic celery-worker-run: diff --git a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/apps/accounts/api/v1/serializers/password.py b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/apps/accounts/api/v1/serializers/password.py index b3bac09..d3b76c6 100644 --- a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/apps/accounts/api/v1/serializers/password.py +++ b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/apps/accounts/api/v1/serializers/password.py @@ -45,7 +45,7 @@ def save(self, **kwargs): class ConfirmResetPasswordSerializer(serializers.Serializer): password = serializers.CharField(max_length=128, write_only=True, style={"input_type": "password"}) - signature = serializers.CharField(max_length=71, write_only=True) + signature = serializers.CharField(max_length=128, write_only=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/contrib/celery.py b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/contrib/celery.py index ac7455f..a4eccd5 100644 --- a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/contrib/celery.py +++ b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/contrib/celery.py @@ -1,4 +1,3 @@ -from ..django import TIME_ZONE as DJANGO_TIME_ZONE from ..environment import env @@ -7,6 +6,6 @@ CELERY_ACCEPT_CONTENT = ["application/json"] CELERY_TASK_SERIALIZER = CELERY_RESULT_SERIALIZER = "json" -CELERY_TIMEZONE = DJANGO_TIME_ZONE +CELERY_TIMEZONE = env.str("{{ cookiecutter.__env_prefix }}TIME_ZONE", default="UTC") CELERYBEAT_SCHEDULE = {} diff --git a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/{{ cookiecutter.project_slug }}.py b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/{{ cookiecutter.project_slug }}.py index acca1f8..54112df 100644 --- a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/{{ cookiecutter.project_slug }}.py +++ b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/settings/{{ cookiecutter.project_slug }}.py @@ -43,3 +43,5 @@ "django.db.backends.schema": {"handlers": ["console"], "level": "DEBUG", "propagate": False}, }, } + +ADMIN_URL = env.str("{{ cookiecutter.__env_prefix }}DJANGO_ADMIN_URL", default="admin/") diff --git a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/urls.py b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/urls.py index e2467cc..118e34a 100644 --- a/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/urls.py +++ b/{{ cookiecutter.project_slug }}/api/{{ cookiecutter.project_slug }}/urls.py @@ -15,7 +15,7 @@ ] urlpatterns = [ - path("admin/", admin.site.urls), + path(settings.ADMIN_URL, admin.site.urls), *api_v1_urlpatterns, ]