From 9982b2544490b86cc299361b96cc5ea6995dd615 Mon Sep 17 00:00:00 2001 From: Saqibur Rahman Date: Tue, 5 Nov 2024 15:13:26 +0600 Subject: [PATCH] feat: add sensible defaults --- .gitignore | 1 + ...mmit-config.yml => .pre-commit-config.yaml | 0 config/settings.py | 51 ++++++++++++++----- pytest.ini | 3 ++ requirements/common.txt | 9 ++++ 5 files changed, 50 insertions(+), 14 deletions(-) rename pre-commit-config.yml => .pre-commit-config.yaml (100%) diff --git a/.gitignore b/.gitignore index 65acb79..1297acc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Current Project Ignores +.ruff_cache/ # OS ignores *.DS_Store diff --git a/pre-commit-config.yml b/.pre-commit-config.yaml similarity index 100% rename from pre-commit-config.yml rename to .pre-commit-config.yaml diff --git a/config/settings.py b/config/settings.py index 1e4d67b..c4e5457 100644 --- a/config/settings.py +++ b/config/settings.py @@ -10,8 +10,12 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ +import os from pathlib import Path +import sentry_sdk +from sentry_sdk.integrations.django import DjangoIntegration + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -20,28 +24,36 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = ( - "django-insecure-$227hjjmuq2e!)o^@2v#+(-=@$v362o@8g#s9!2)tjn1)1a" -) +SECRET_KEY = "django-insecure-$227hjjmuq2e!)o^@2v#+(-=@$v362o@8g#s9!2)tjn1)1a" ALLOWED_HOSTS = [] - -# Application definition - -INSTALLED_APPS = [ +DEFAULT_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", +] + +THIRD_PARTY_APPS = [ + "rest_framework", + "corsheaders", + "storages", + "django_filters", +] + +SELF_APPS = [ "apps.core", ] +INSTALLED_APPS = DEFAULT_APPS + THIRD_PARTY_APPS + SELF_APPS + MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", + "corsheaders.middleware.CorsMiddleware", # Third-Party Middleware "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", @@ -73,13 +85,13 @@ WSGI_APPLICATION = "config.wsgi.application" # https://docs.djangoproject.com/en/5.0/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'your-db-name', - 'USER': 'your-db-user', - 'PASSWORD': 'your-db-user-password', - 'HOST': 'your-db-host', - 'PORT': 'your-db-port', + "default": { + "ENGINE": "django.db.backends.postgresql_psycopg2", + "NAME": "your-db-name", + "USER": "your-db-user", + "PASSWORD": "your-db-user-password", + "HOST": "your-db-host", + "PORT": "your-db-port", } } @@ -126,3 +138,14 @@ STATIC_URL = "static/" DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" DEBUG = True + +### --- SENTRY SETTINGS --- ### +if not DEBUG: + sentry_sdk.init( + dsn=os.environ("SENTRY_DSN"), + integrations=[ + DjangoIntegration(), + ], + traces_sample_rate=0.5, + send_default_pii=False, + ) diff --git a/pytest.ini b/pytest.ini index e69de29..7a4fb9b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +DJANGO_SETTINGS_MODULE = config.settings +python_files = tests.py test_*.py *_tests.py diff --git a/requirements/common.txt b/requirements/common.txt index e69de29..4fe8495 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -0,0 +1,9 @@ +Django +djangorestframework +django-cors-headers +django-filter +django-storages +psycopg2-binary==2.9.9 +Pillow +sentry-sdk +gunicorn