import os from pathlib import Path import sentry_sdk from sentry_sdk.integrations.django import DjangoIntegration from .utils import get_op_config op_config = get_op_config() print(op_config) SCOPE = op_config['settings.SCOPE'] sentry_sdk.init( dsn=op_config['settings.SENTRY_DSN'], integrations=[DjangoIntegration()], environment=SCOPE, send_default_pii=False, traces_sample_rate=1.0, ) # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = op_config['settings.SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = op_config.get("settings.DEBUG", "0") in ["1", "true"] ALLOWED_HOSTS = op_config.get("settings.ALLOWED_HOSTS", "127.0.0.1,localhost").split(",") # Application definition INSTALLED_APPS = [ "rest_framework", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "corsheaders", "core", "api", "game", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "corsheaders.middleware.CorsMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] ROOT_URLCONF = "app.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", ], }, }, ] WSGI_APPLICATION = "app.wsgi.application" AUTH_USER_MODEL = "core.User" # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", "NAME": op_config['database.name'], "USER": op_config['database.user'], "PASSWORD": op_config['database.password'], "HOST": op_config['database.host'], "PORT": op_config['database.port'], "OPTIONS": {"charset": "utf8mb4"}, } } # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" }, {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"}, {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"}, {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"}, ] # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = "/static/" # Some Django Rest Framework parameters REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.AllowAny"], "DEFAULT_AUTHENTICATION_CLASSES": [ "rest_framework.authentication.TokenAuthentication" ], "DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",), } if DEBUG is True: CORS_ALLOW_ALL_ORIGINS = True DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'