settings.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. """
  2. Django settings for UnTube project.
  3. Generated by 'django-admin startproject' using Django 3.2.3.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/3.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.2/ref/settings/
  8. """
  9. import os
  10. from pathlib import Path
  11. from UnTube.secrets import SECRETS
  12. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  13. # PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
  14. BASE_DIR = Path(__file__).resolve().parent.parent
  15. # BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  16. # Quick-start development settings - unsuitable for production
  17. # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
  18. # SECURITY WARNING: keep the secret key used in production secret!
  19. SECRET_KEY = SECRETS['SECRET_KEY']
  20. YOUTUBE_V3_API_KEY = SECRETS['YOUTUBE_V3_API_KEY']
  21. # SECURITY WARNING: don't run with debug turned on in production!
  22. DEBUG = True
  23. ALLOWED_HOSTS = ['127.0.0.1', 'bakaabu.pythonanywhere.com']
  24. # Application definition
  25. INSTALLED_APPS = [
  26. 'django.contrib.admin',
  27. 'django.contrib.auth',
  28. 'django.contrib.contenttypes',
  29. 'django.contrib.sessions',
  30. 'django.contrib.messages',
  31. 'django.contrib.staticfiles',
  32. 'django.contrib.humanize', # A set of Django template filters useful for adding a “human touch” to data.
  33. 'django.contrib.sites',
  34. 'allauth',
  35. 'allauth.account',
  36. 'allauth.socialaccount',
  37. 'allauth.socialaccount.providers.google', # specifies google as OAuth provider
  38. 'crispy_forms',
  39. 'apps.users', # has stuff related to user management in it (login, signup, show homepage, import)
  40. 'apps.main', # main app, shows user their homepage
  41. 'apps.manage_playlists',
  42. 'apps.charts',
  43. 'apps.search',
  44. ]
  45. CRISPY_TEMPLATE_PACK = 'bootstrap4'
  46. MIDDLEWARE = [
  47. 'django.middleware.security.SecurityMiddleware',
  48. 'django.contrib.sessions.middleware.SessionMiddleware',
  49. 'django.middleware.common.CommonMiddleware',
  50. 'django.middleware.csrf.CsrfViewMiddleware',
  51. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  52. 'django.contrib.messages.middleware.MessageMiddleware',
  53. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  54. ]
  55. ROOT_URLCONF = 'UnTube.urls'
  56. TEMPLATES = [
  57. {
  58. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  59. 'DIRS': [BASE_DIR / 'templates'],
  60. # 'DIRS': [os.path.join(BASE_DIR, "templates")],
  61. 'APP_DIRS': True,
  62. 'OPTIONS': {
  63. 'context_processors': [
  64. 'django.template.context_processors.debug',
  65. 'django.template.context_processors.request',
  66. 'django.contrib.auth.context_processors.auth',
  67. 'django.contrib.messages.context_processors.messages',
  68. ],
  69. },
  70. },
  71. ]
  72. AUTHENTICATION_BACKENDS = [
  73. 'django.contrib.auth.backends.ModelBackend',
  74. 'allauth.account.auth_backends.AuthenticationBackend'
  75. ]
  76. SOCIALACCOUNT_PROVIDERS = {
  77. 'google': {
  78. 'SCOPE': [
  79. 'profile',
  80. 'email',
  81. 'https://www.googleapis.com/auth/youtube',
  82. ],
  83. 'AUTH_PARAMS': {
  84. # To refresh authentication in the background, set AUTH_PARAMS['access_type'] to offline.
  85. 'access_type': 'offline',
  86. }
  87. }
  88. }
  89. SITE_ID = 7
  90. LOGIN_URL = '/'
  91. LOGIN_REDIRECT_URL = '/home/'
  92. LOGOUT_REDIRECT_URL = '/home/'
  93. WSGI_APPLICATION = 'UnTube.wsgi.application'
  94. # Database
  95. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  96. DATABASES = {
  97. 'default': {
  98. 'ENGINE': 'django.db.backends.sqlite3',
  99. 'NAME': BASE_DIR / 'db.sqlite3',
  100. }
  101. }
  102. # DATABASES = {}
  103. # DATABASES['default'] = dj_database_url.config(conn_max_age=600)
  104. # DATABASE_URL = os.environ['DATABASE_URL']
  105. # conn = psycopg2.connect(DATABASE_URL, sslmode='require')
  106. # Password validation
  107. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  108. AUTH_PASSWORD_VALIDATORS = [
  109. {
  110. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  111. },
  112. {
  113. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  114. },
  115. {
  116. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  117. },
  118. {
  119. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  120. },
  121. ]
  122. # Internationalization
  123. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  124. LANGUAGE_CODE = 'en-us'
  125. TIME_ZONE = 'UTC'
  126. USE_I18N = True
  127. USE_L10N = True
  128. USE_TZ = True
  129. # Static files (CSS, JavaScript, Images)
  130. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  131. STATIC_URL = '/static/'
  132. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  133. # STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  134. # Default primary key field type
  135. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  136. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  137. # django_heroku.settings(locals())
  138. # options = DATABASES['default'].get('OPTIONS', {})
  139. # options.pop('sslmode', None)