From bddd16572d2dd21ad2c637526ab2f43769ad0e7b Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 20 Mar 2025 12:51:43 +0100 Subject: [PATCH] Update config --- .../config/settings/base.py | 29 ++++++++++++++----- .../config/settings/local.py | 2 +- .../docker-compose.local.yml | 12 ++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 22876096c..8b57c3b9d 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -4,9 +4,11 @@ {% if cookiecutter.use_celery == 'y' -%} import ssl {%- endif %} +from datetime import timedelta from pathlib import Path import environ +from django.utils.translation import gettext_lazy as _ BASE_DIR = Path(__file__).resolve(strict=True).parent.parent.parent # {{ cookiecutter.project_slug }}/ @@ -28,14 +30,11 @@ DEBUG = env.bool("DJANGO_DEBUG", False) # In Windows, this must be set to your system time zone. TIME_ZONE = "{{ cookiecutter.timezone }}" # https://docs.djangoproject.com/en/dev/ref/settings/#language-code -LANGUAGE_CODE = "en-us" +LANGUAGE_CODE = "sr-latn" # https://docs.djangoproject.com/en/dev/ref/settings/#languages -# from django.utils.translation import gettext_lazy as _ -# LANGUAGES = [ -# ('en', _('English')), -# ('fr-fr', _('French')), -# ('pt-br', _('Portuguese')), -# ] +LANGUAGES = [ + ("sr-latn", _("Serbian")), +] # https://docs.djangoproject.com/en/dev/ref/settings/#site-id SITE_ID = 1 # https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n @@ -97,6 +96,10 @@ THIRD_PARTY_APPS = [ "rest_framework.authtoken", "corsheaders", "drf_spectacular", + "dj_rest_auth", + "dj_rest_auth.registration", + "rest_framework_simplejwt", + "rest_framework_simplejwt.token_blacklist", {%- endif %} {%- if cookiecutter.frontend_pipeline == 'Webpack' %} "webpack_loader", @@ -240,6 +243,8 @@ CSRF_COOKIE_HTTPONLY = True # https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options X_FRAME_OPTIONS = "DENY" +DATA_UPLOAD_MAX_NUMBER_FIELDS = 10_000 + # EMAIL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend @@ -367,6 +372,7 @@ STATICFILES_FINDERS += ["compressor.finders.CompressorFinder"] # django-rest-framework - https://www.django-rest-framework.org/api-guide/settings/ REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": ( + "rest_framework_simplejwt.authentication.JWTAuthentication", "rest_framework.authentication.SessionAuthentication", "rest_framework.authentication.TokenAuthentication", ), @@ -374,6 +380,15 @@ REST_FRAMEWORK = { "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", } +REST_AUTH = { + "USE_JWT": True, + "JWT_AUTH_HTTPONLY": False, +} + +SIMPLE_JWT = { + "ACCESS_TOKEN_LIFETIME": timedelta(days=env.int("SIMPLE_JWT_ACCESS_TOKEN_LIFETIME", default=180)), +} + # django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup CORS_URLS_REGEX = r"^/api/.*$" diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index f63151239..1c822a3bf 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -17,7 +17,7 @@ SECRET_KEY = env( default="!!!SET DJANGO_SECRET_KEY!!!", ) # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts -ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104 +ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1", "*"] # noqa: S104 # CACHES # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/docker-compose.local.yml b/{{cookiecutter.project_slug}}/docker-compose.local.yml index eced08ee8..9c00bc8cb 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.local.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.local.yml @@ -23,10 +23,19 @@ services: env_file: - ./.envs/.local/.django - ./.envs/.local/.postgres + - path: ./.env # Use this .env file to override the values .envs/.local/.django + - required: false ports: - '8000:8000' command: /start + interpreter: + <<: *django + profiles: + - interpreter + container_name: gebi_local_interpreter + ports: [] + postgres: build: context: . @@ -38,6 +47,8 @@ services: - {{ cookiecutter.project_slug }}_local_postgres_data_backups:/backups env_file: - ./.envs/.local/.postgres + ports: + - "5432:5432" {%- if cookiecutter.use_mailpit == 'y' %} @@ -46,6 +57,7 @@ services: container_name: {{ cookiecutter.project_slug }}_local_mailpit ports: - "8025:8025" + - "1025:1025" {%- endif %} {%- if cookiecutter.use_celery == 'y' %}