achief

Base.py

May 14th, 2023
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.02 KB | Software | 0 0
  1. import os
  2. from pathlib import Path
  3.  
  4. # used to generate the SECRET_KEY
  5. from django.core.exceptions import ImproperlyConfigured
  6. from dotenv import load_dotenv
  7.  
  8. load_dotenv()
  9.  
  10. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  11. BASE_DIR = Path(__file__).resolve().parent.parent
  12.  
  13.  
  14. # Quick-start development settings - unsuitable for production
  15. # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
  16.  
  17.  
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. DEBUG = True
  20.  
  21.  
  22. # Application definition
  23.  
  24. INSTALLED_APPS = [
  25.     "django.contrib.admin",
  26.     "django.contrib.auth",
  27.     "django.contrib.contenttypes",
  28.     "django.contrib.sessions",
  29.     "django.contrib.messages",
  30.     "django.contrib.staticfiles",
  31.     # External Packages
  32.     "rest_framework",
  33.     "drf_spectacular",
  34. ]
  35.  
  36. MIDDLEWARE = [
  37.     "django.middleware.security.SecurityMiddleware",
  38.     "whitenoise.middleware.WhiteNoiseMiddleware",
  39.     "django.contrib.sessions.middleware.SessionMiddleware",
  40.     "django.middleware.common.CommonMiddleware",
  41.     "django.middleware.csrf.CsrfViewMiddleware",
  42.     "django.contrib.auth.middleware.AuthenticationMiddleware",
  43.     "django.contrib.messages.middleware.MessageMiddleware",
  44.     "django.middleware.clickjacking.XFrameOptionsMiddleware",
  45. ]
  46.  
  47. ROOT_URLCONF = "project.urls"
  48.  
  49. TEMPLATES = [
  50.     {
  51.         "BACKEND": "django.template.backends.django.DjangoTemplates",
  52.         "DIRS": [],
  53.         "APP_DIRS": True,
  54.         "OPTIONS": {
  55.             "context_processors": [
  56.                 "django.template.context_processors.debug",
  57.                 "django.template.context_processors.request",
  58.                 "django.contrib.auth.context_processors.auth",
  59.                 "django.contrib.messages.context_processors.messages",
  60.             ],
  61.         },
  62.     },
  63. ]
  64.  
  65. WSGI_APPLICATION = "project.wsgi.application"
  66.  
  67. # Database section
  68.  
  69. # Password validation
  70. # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
  71.  
  72. AUTH_PASSWORD_VALIDATORS = [
  73.     {
  74.         "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  75.     },
  76.     {
  77.         "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
  78.     },
  79.     {
  80.         "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
  81.     },
  82.     {
  83.         "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
  84.     },
  85. ]
  86.  
  87.  
  88. # Internationalization
  89. # https://docs.djangoproject.com/en/4.2/topics/i18n/
  90.  
  91. LANGUAGE_CODE = "en-us"
  92.  
  93. TIME_ZONE = "UTC"
  94.  
  95. USE_I18N = True
  96.  
  97. USE_TZ = True
  98.  
  99.  
  100. # Static files (CSS, JavaScript, Images)
  101. # https://docs.djangoproject.com/en/4.2/howto/static-files/
  102.  
  103. STATIC_URL = "static/"
  104.  
  105. # Default primary key field type
  106. # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
  107.  
  108. DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
  109.  
  110. REST_FRAMEWORK = {
  111.     "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
  112. }
  113.  
  114. SPECTACULAR_SETTINGS = {
  115.     "TITLE": "My Cool API Docs",
  116. }
  117.  
Advertisement
Add Comment
Please, Sign In to add comment