Guest User

Untitled

a guest
Jun 17th, 2024
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.33 KB | None | 0 0
  1. from pathlib import Path
  2.  
  3. import environ
  4. from corsheaders.defaults import default_headers
  5.  
  6. env = environ.Env()
  7. environ.Env.read_env()
  8.  
  9. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  10. BASE_DIR = Path(__file__).resolve().parent.parent
  11.  
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
  14.  
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'django-insecure-!h93gq@_^p9se+^k1=tfusk747ixc&)%1@nxi%j$1!ip98-*=$'
  17.  
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. DEBUG = True
  20.  
  21. ALLOWED_HOSTS = ['ByteBazaar.pythonanywhere.com', 'bytebazaar.pythonanywhere.com', '127.0.0.1', 'localhost']
  22.  
  23. INSTALLED_APPS = [
  24.     'django.contrib.admin',
  25.     'django.contrib.auth',
  26.     'django.contrib.contenttypes',
  27.     'django.contrib.sessions',
  28.     'django.contrib.messages',
  29.     'django.contrib.staticfiles',
  30.  
  31.     'rest_framework',
  32.     'corsheaders',
  33.     'rest_framework.authtoken',
  34.     'phonenumber_field',
  35.  
  36.     'PC_shop_backend.api',
  37.     'PC_shop_backend.common',
  38.     'PC_shop_backend.catalog',
  39.     'PC_shop_backend.cart',
  40. ]
  41.  
  42. MIDDLEWARE = [
  43.     'corsheaders.middleware.CorsMiddleware',
  44.     'django.middleware.security.SecurityMiddleware',
  45.     'django.contrib.sessions.middleware.SessionMiddleware',
  46.     'django.middleware.common.CommonMiddleware',
  47.     'django.middleware.csrf.CsrfViewMiddleware',
  48.     'django.contrib.auth.middleware.AuthenticationMiddleware',
  49.     'django.contrib.messages.middleware.MessageMiddleware',
  50.     'django.middleware.clickjacking.XFrameOptionsMiddleware',
  51. ]
  52.  
  53.  
  54. REST_FRAMEWORK = {
  55.     'DEFAULT_AUTHENTICATION_CLASSES': [
  56.         'rest_framework.authentication.TokenAuthentication',
  57.     ],
  58.     # 'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.AllowAny'],
  59. }
  60.  
  61. CORS_ALLOWED_ORIGINS = [
  62.     "http://localhost:5173",
  63.     "http://127.0.0.1:5173",
  64. ]
  65. CORS_ALLOW_CREDENTIALS = True
  66.  
  67. CORS_ALLOW_HEADERS = list(default_headers) + [
  68.     'Cart_token',
  69.     'cart_token',
  70.     'Cookie',
  71. ]
  72.  
  73. CSRF_TRUSTED_ORIGINS = [
  74.     'http://localhost:5173',
  75.     'http://127.0.0.1:5173',
  76. ]
  77.  
  78.  
  79.  
  80. ROOT_URLCONF = 'PC_shop_backend.urls'
  81.  
  82. TEMPLATES = [
  83.     {
  84.         'BACKEND': 'django.template.backends.django.DjangoTemplates',
  85.         'DIRS': []
  86.         ,
  87.         'APP_DIRS': True,
  88.         'OPTIONS': {
  89.             'context_processors': [
  90.                 'django.template.context_processors.debug',
  91.                 'django.template.context_processors.request',
  92.                 'django.contrib.auth.context_processors.auth',
  93.                 'django.contrib.messages.context_processors.messages',
  94.             ],
  95.         },
  96.     },
  97. ]
  98.  
  99. WSGI_APPLICATION = 'PC_shop_backend.wsgi.application'
  100.  
  101. DATABASES = {
  102.     'default': {
  103.         'ENGINE': env('DATABASE_ENGINE'),
  104.         'NAME': env('DATABASE_NAME'),
  105.         'USER': env('DATABASE_USER'),
  106.         'PASSWORD': env('DATABASE_PASS'),
  107.         'HOST': env('DATABASE_HOST'),
  108.         'PORT': env('DATABASE_PORT')
  109.     }
  110. }
  111.  
  112.  
  113. # DATABASES = {
  114. #     'default': {
  115. #         'ENGINE': 'django.db.backends.sqlite3',
  116. #         'NAME': BASE_DIR / 'db.sqlite3',
  117. #     }
  118. # }
  119.  
  120.  
  121. # AUTH_PASSWORD_VALIDATORS = [
  122. #     {
  123. #         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  124. #     },
  125. #     {
  126. #         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  127. #     },
  128. #     {
  129. #         'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  130. #     },
  131. #     {
  132. #         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  133. #     },
  134. # ]
  135.  
  136. # Internationalization
  137. # https://docs.djangoproject.com/en/4.2/topics/i18n/
  138.  
  139. LANGUAGE_CODE = 'en-us'
  140.  
  141. TIME_ZONE = 'UTC'
  142.  
  143. USE_I18N = True
  144.  
  145. USE_TZ = True
  146.  
  147. # Static files (CSS, JavaScript, Images)
  148. # https://docs.djangoproject.com/en/4.2/howto/static-files/
  149.  
  150.  
  151. STATIC_URL = '/static/'
  152.  
  153. STATICFILES_DIRS = [
  154.     BASE_DIR / 'static',
  155. ]
  156.  
  157. STATIC_ROOT = BASE_DIR / "staticfiles"
  158.  
  159. MEDIA_ROOT = BASE_DIR / 'media'
  160. MEDIA_URL = "/media/"
  161.  
  162.  
  163. GMAIL_USERNAME = env('EMAIL_HOST_USER')
  164. GMAIL_APP_PASSWORD = env('EMAIL_HOST_PASSWORD')
  165.  
  166.  
  167. SESSION_ENGINE = 'django.contrib.sessions.backends.db'
  168. SESSION_COOKIE_NAME = 'sessionid'
  169. SESSION_SAVE_EVERY_REQUEST = True
  170. SESSION_EXPIRE_AT_BROWSER_CLOSE = True
  171.  
Advertisement
Add Comment
Please, Sign In to add comment